## Arithmetic Drill

### December 31, 2010

Children just learning the basic facts of arithmetic need repetitious drill to certify their knowledge, something that a computer does well. Toy stores purvey many brightly-colored plastic boxes that do the job, at a price. Today’s exercise asks you to do the same, minus the plastic box. Consider the following dialog, where the computer’s output is in `roman` and the child’s response is in `italic`:

```4 + 4 = 8 Right! 8 + 3 = 12 Wrong, try again! 8 + 3 = 11 Right! 9 + 4 = 13 Right! 7 + 8 = ? 15 9 + 5 = 14 Right! 8 + 0 = ^Z Goodbye!```

After the drill program presents a problem, the child either enters his answer, asks for help by entering a question mark, or quits by entering an end-of-file. Correct answers are rewarded, incorrect answers cause the problem to be asked again.

Your task is to write a program that drills children on their addition facts. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2