The objective of this project is to teach basic programming concepts using the Scratch programming language by creating a simple, interactive calculator. This calculator will allow users to input two numbers and choose an operation (addition, subtraction, multiplication, or division) to perform on those numbers. The result will then be displayed on the screen.
1- User Interaction:
The calculator will ask the user for input through the "ask" block to collect two numbers and an operation (like +, –, ×, ÷).
The program will handle the input in a way that allows the user to enter these values interactively, instead of hardcoding them.
2- Basic Operations:
The calculator will perform basic arithmetic operations on the two numbers based on the user's input:
Addition (+)
Subtraction (-)
Multiplication (×)
Division (÷)
After the operation is performed, the result will be displayed.
3- Output and Display:
The program will output the result of the operation on the screen, either using a "say" block or by displaying the result in a variable that the user can see updated in real-time.
Error Handling (Optional):
The program can be enhanced to handle potential errors such as:
Dividing by zero, which could display a special message.
Invalid input (e.g., non-numeric values or unsupported operations).
We must go to the Variables category to create the three variables a, b and result.
Program insertion in the code area of the cat sprite:
We start by inserting the green flag event block.
Then we hide the result variable.
Then we ask the user to give the value of the variable a.
The value entered in the predefined response variable is assigned.
We assign the value of the predefined response variable to variable a.
We do the same thing to enter the value of the variable b.
Finally here is the final program of the sprite cat.
This program lets you enter two values from the keyboard and store them respectively in the two variables a and b.
Go to the new sprites section and select the brush icon.
Draw the addition sprite using the drawing editor.
Go to the code area of the addition sprite and insert these blocks:
When you click on the addition sprite with the mouse, the program displays the result of the addition in the result variable.
Go to the new sprites section and select the paint icon.
Draw the subtraction sprite using the drawing editor.
Go to the code area of the subtraction sprite and insert these blocks:
When you click on the subtraction sprite with the mouse, the program displays the result of the subtraction in the result variable.
Go to the new sprites section and select the brush icon.
Draw the sprite product using the drawing editor.
Go to the code area of the product sprite and insert these blocks:
When you click on the sprite produced with the mouse, the program displays the result of the product in the result variable.
1) Go to the new sprites section and select the paint icon.
2) Draw the division sprite using the drawing editor.
3) Go to the code area of the division sprite and insert these blocks:
When you click on the sprite produced with the mouse, the program displays the result of the division in the result variable.
To avoid division by 0 which is impossible, we used the block if then to check the value of variable b: if b=0 we display « Division not possible » in the result variable and if b is different from 0, we display the result of the division.
Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info