Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
- a nonzero value should be added into a subtotal;
- a zero value should cause the subtotal to be printed and reset to zero;
- 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.
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: 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started