Mathematics Scratch
Hard
60 mins
235 points
What you need:
  • Computer/laptop

Calculator Robot

In this lesson we will create our own calculator and program it to do addition, subtraction, multiplication and division sums. We'll also give the calculator it's own personality!

1 - Create a new Scratch project

Create a new Scratch project and delete the cat sprite.

scratch.mit.edu

2 - Add the Retro Robot sprite

We're going to use a robot sprite to ask what type of sum, what numbers and also say the answer. Open the sprite library and add the Retro Robot sprite to your project.

Drag the robot to the middle of the stage area.


3 - Add sprites for the sum types

We're going to create a sprite for each different type of sum and then program these to tell the robot what type of sum we wish to do.

Sum TypeSign
addition
+
subtraction
-
multiplication 
x
division
/

To create these sprites click on the 'Paint' when adding a new sprite. This opens the sprite editor.

Follow these steps to create the addition sprite:

  1. Choose the colour you wish to make your sprites
  2. Click on the text tool (the T button) on the left hand side
  3. Click in the middle of the editor area
  4. Type +
  5. Click anywhere on the editor area, you will see a box appear around the +
  6. Use the box to increase the size of the +
  7. Go to your stage area and drag the new + sprite to the bottom

Repeat the above steps to create a minus sign (-), a multiplication sign (x) and a division sign (/). Line them up at the bottom of the stage area.



4 - Create the variables

We will need to create 3 variables to help us do the sums. In the Data palette, create 3 new variables by clicking the 'Make a Variable' button.

  1. 'number1' this will store the first number in the sum
  2. 'number2' this will store the second number in the sum
  3. 'result' this will store the answer of the sum

When you create your first variable you will notice that new blocks for variables become available to use in the Data palette.

5 - Switch the robot calculator on

When the robot calculator gets switched on (using the green flag) it will introduce itself and ask what type of sum you want to do. We'll also hide the variables as we don't want them to display on the stage.

Add the following code to the Retro Robot sprite.

when green flag clicked hide variable [number1 v] hide variable [number2 v] hide variable [result v] say [Hi I'm Calco the robot, I can do sums in my head!] for (2) seconds say [Choose which type of sum you want to do.]

Notice that for the first sentence we use the say Hello! for 2 secs block and for the second we use the say Hello!  block. This is because we want the first sentence to display for 2 seconds and then we want the second sentence to remain until something else happens.

Join our club 😃

To view the remaining 6 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more