Answered step by step
Verified Expert Solution
Link Copied!

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:

  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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago