Question: Integer surplusValue and integer inputNumber are read from input. Read the remaining integers from input into inputNumber until 1 0 0 0 is read. For

Integer surplusValue and integer inputNumber are read from input. Read the remaining integers from input into inputNumber until 1000 is read. For each integer read before 1000:
If the integer is non-positive, output the non-positive integer followed by " is bad data" and a newline.
Otherwise, subtract the positive integer from surplusValue.
Ex: If the input is:
77-1786171000
then the output is:
-17 is bad data The total after subtracting all positive values is 46
Note: The sentinel value is 1000. The value of surplusValue may go negative.
Update result with the sum of result and numInput.
Then, read the next integer from input into variable numInput.
The integer that is less than or equal to -1 should not be included in the sum.

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 Programming Questions!