Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how could you make a calculator in scratch
- unitedcoderz
-
4 posts
how could you make a calculator in scratch
any ideas of how you could make a calculator on scratch that can answer any math equation?
- Scratch-Minion
-
1000+ posts
how could you make a calculator in scratch
You could make buttons for 0,1,2,3,4,5,6,7,8,9 and +,-,x,/ and =
First, when the user clicks numbers, use the join operator to join them into one long number (Number1).
Then the user will click +,-,* or /. Store this operator in a variable eg. set Operator to +
Thirdly, get the second number (Number2) by again using the join operator as they enter numbers.
Finally the user will click =. Then you can combine Number1 and Number2 using the Operator and display the answer.
You will need more code if you want to add more features (eg. a clear button) or multiple calculations with intermediate results.
You can type Calculator in the Scratch Search Bar to see example projects.
First, when the user clicks numbers, use the join operator to join them into one long number (Number1).
Then the user will click +,-,* or /. Store this operator in a variable eg. set Operator to +
Thirdly, get the second number (Number2) by again using the join operator as they enter numbers.
Finally the user will click =. Then you can combine Number1 and Number2 using the Operator and display the answer.
You will need more code if you want to add more features (eg. a clear button) or multiple calculations with intermediate results.
You can type Calculator in the Scratch Search Bar to see example projects.
- Discussion Forums
- » Help with Scripts
-
» how could you make a calculator in scratch