We have had a few questions on how to make a calculator calculate. First, here are a few reasons a calculator might be valuable:

  • Accounting or financial training
  • Teaching mathematics or calculator skills

Anyway a calculator can let the learner focus on the content, the formulas, and how to get where they need to be instead of focusing all their time and effort on calculating.

So how do we make a calculator? We are going to use Storyline's capabilities for this explanation. Generally you need a few variables. Lets start with the following:

  • currentNum = the current number (also the number that gets displayed)
  • operation = storage of what operation (addition, subtraction, multiplication, or division) is going to be performed when the user clicks the equal sign
  • standbyNum = storage of what number is going to be used

So to start there, you can use Storyline, with a few triggers, to start calculating:

  1. currentNum is initially 0
  2. User presses the plus sign (stored in operation as "add")
  3. User presses 7 (stored in standbyNum)
  4. User presess = and the magic happens

The trigger will work like this: Add currentNum to standbyNum when user clicks the button if operation is equal to "add".

If the learner wants to type 22, you need to take 2 (the first number), multiply it by 10 (20) then add 2 again (22). They want another number? Multiply by 10 again, rinse and repeat.

It becomes a little more complicated when you add decimals. Storyline only allows for two decimal places. If you want to work with decimals or negative numbers, you always have to get the number into a whole number. No decimal point. No negative. You need to keep track of what you multiplied the number by and if it was a negative. Then perform the operation and reverse the process. You will then end up with exactly what you expect.

Here is a calculator we built: http://www.elearninglocker.com/portfolio-items/storyline-template-calculator/

Happy calculating!