Me: Turn it on, or open the appMost programming languages (including Tom's Kitchen Computer) already know how to do simple arithmetic. I did a lot of work on early microprocessors, and they didn't know anything. I had to tell it how to add and subtract numbers longer than one digit. I had to tell it how to do long multiplication and long division. Do they even teach that in school any more? Why bother? You use a calculator.
Calc: Show "0." on the display
Me: Press the '2' button
Calc: Show "2." on the display
Me: Press the '+' button
Calc: (no change, or else) Show '2+'
Me: Press the '3' button
Calc: Show "3." on the display (or maybe '2+3')
Me: Press the '=' button
Calc: Show "5." on the display
The point is, if you assume the computer already knows how to do arithmetic (we can do that, especially when we are writing our program in English), then to write a Calculator program is pretty easy. You might even get it running today. We start with the list of steps (above), but the program does not tell the user what to do, only what the calculator does each time after the user does something. The "Me:" lines above, those we will turn into input. The "Calc:" lines we -- meaning you -- will turn into your program.
OK, the user turned your calculator on (they clicked on the "Run This Program" button). Write down (in English) what is the single first thing your calculator must do, then turn the page.
<<Previous | ToC | Next >>
[2021 May 12]