🛠️ Project: the calculator
Section 3: Typing and mathsLesson 3.2 · ⏱ 14 min
🎯 Project goal
Two numbers in two boxes, and four buttons + − × ÷, and the result big under them. And it doesn't accept dividing by zero.



- 🔢 number from turns the typed text into a number. Without it 12 + 3 becomes “123”, because the app sticks the two texts together.
- if … else: if the second number is 0 we write a message, otherwise we divide.
🖥️ What happens on the stage?
We tried it in the lab: 12 + 3 = 15, 12 ÷ 3 = 4, 12 ÷ 0 → “You can't divide by zero”, and 12 × 3 = 36.
- Add a “Clear” button that empties the two boxes.
- Add a power button ^ from the maths block.
📌 Another example: the area of a rectangle
Length × width.



✍️ Practise
Practice: a calculator.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
An adding-only calculator.
👀 Show the solution🙈 Hide the solution



Result: 12 + 7 = 19
Medium
The average of two numbers.
👀 Show the solution🙈 Hide the solution



Result: (10 + 20) ÷ 2 = 15
Hard
Which of the two numbers is bigger?
👀 Show the solution🙈 Hide the solution



Result: The bigger: 42

