2.1 12 digit product codes: Check if total is a multiple of 10 (entered one at a time)

Scratch solution

View solution

This is just one of many possible solutions:

when green flag clicked
set [total 1 v] to [0]
set [total 2 v] to [0]
set [counter v] to [1]
repeat (6)
  ask (join (join [Enter digit ] (counter)) [ of the product code:]) and wait
  change [counter v] by (1)
  change [total 1 v] by (answer)
  ask (join (join [Enter digit ] (counter)) [ of the product code:]) and wait
  change [counter v] by (1)
  change [total 2 v] by (answer)
end
set [total v] to (((total 1) * (3)) + (total 2))
say (join [Total: ] (total))

Back to programming challenge