Question: In python. Adding Calculator Write a program that simulates an adding machine. Input to the program will be integers, submitted one per line. Input should

In python.

Adding Calculator

Write a program that simulates an adding machine. Input to the program will be integers, submitted one per line. Input should be handled as follows:

  1. a nonzero value should be added into a subtotal;
  2. a zero value should cause the subtotal to be printed and reset to zero;
  3. two consecutive zeroes should cause the total (not subtotal) of all the values input to be printed and the program to be terminated.

Heres an example of how the program should work. However, it is only an example. Your program should work for any test case.

Input is in red and output is in blue. Your program does not need to display colors, they are show here for illustration only so that you can distinguish input and output.

In python. Adding Calculator Write a program that simulates an adding machine.

Test Case 1: 5 6 subtotal: 11 -3 -2 5 subtotal: 0 13 - 13 subtotal: 8 total: 19 Test Case 2: 8 subtotal: 8 8 subtotal: 8 8 subtotal: 8 8 subtotal: 8 8 subtotal: 8 total: 40 Test Case 3: subtotal: 0 total: 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!