Click the green flag and follow the instructions.
When you write programs like this, you wish there were a scripting engine for Scratch! I actually wrote the logic in C first and then created the Scratch scripts.