Add in parts (add two 1-digit numbers)

Challenge Level: Growing experience

Learning outcomes

Students will be able to:


Write a program that asks the user to enter two numbers less than 10 (entering the larger number first). If the numbers add up to 10 or less you can just display the two numbers, but if they add up to more than 10, then by splitting numbers into parts, the program should display how they can be added together by making a sum up to 10 (e.g. if the numbers entered are 6 and 5 it displays 6+5 as (6+4)+1). It then displays the answer which is 11.

Testing examples:

Your program should display the outputs shown in this table for the given inputs provided;

Input Output
(8 + 2) + 5 = 15
(9 + 1) + 2 = 12
5 + 4 = 9



What it should look like

Click on the green flag to see the expected output of your program.

Recommended blocks
when green flag clicked
set [num1 v] to (answer)

set [num2 v] to (answer)

set [ten minus num1 v] to ((10) - (num1))

set [left from num2 v] to ((num2) - (ten minus num1))
ask [Enter the 1st number:] and wait

ask [Enter the 2nd number:] and wait
say [Enter two numbers less than 10. Enter the larger number first.] for (3) secs

say (join (join (join (num1) [+]) (num2)) [=?]) for (3) secs

say (join (join (join (join (join (join (join [To make ] (num1)) [ a tidy number I am splitting ]) (num2)) [ into a ]) (ten minus num1)) [ and a ]) (left from num2)) for (5) secs

say (join (join [(] (join (join (num1) [+]) (join (join (join (ten minus num1) [)]) [+]) (left from num2)))) [=]) for (5) secs

say (join [] ((num1) + (num2)))

say (join (join (join (num1) [+]) (num2)) [=?]) for (5) secs

say ((num1) + (num2))
if <((num1) + (num2)) > [10]> then
  • Make two variables called “num1” and “num2” and set their values to the inputs entered by the user.
  • To make “num1” a tidy number, split “num2” into 2 parts (call these variables “10 minus num1” and “left from num2”) so the sum of one part and “num1” is equal to 10.

Show Scratch solution