"Write a program that simulates an adding machine. When zero is entered it should print the subtotal of all the numbers entered from the last zero that was entered and reset the subtotal. When two consecutive zeroes are entered it should print the total (not the subtotal) of all the numbers entered and terminate the program. Example:
1
2
3
0
subtotal 6
8
0
subtotal 8
0
total 14
Be careful this program needs a bit more thought than you might think at first. To get full credit you must make sure it also works for the 0-0 case. Example:
0
subtotal 0
0
total 0"
I am very confuse and have no idea how to complete or start this assignment. I would greatly appreciate any advise or help given to me.
My school's computer lab mostly uses borland c++ 4.x.x
Start by not thinking about code. Think about the problem. How would you do this if you were the computer, and someone else was telling you the numbers?
I expect something like this:
Person tells you a number. Write it down.
Person tells you another number. Add it to what you already have, making new total.
Person tells you another number. Add it to what you already have, making new total.
etc.
etc.
...
Person says zero. Tell them your current total. Cross out your total, write zero, start again.
Now translate that into code. Programming is more about thinking about the problem in a logical way than it is about memorising syntax.