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 is read. For each integer read before :
If the integer is nonpositive, output the nonpositive integer followed by is bad data" and a newline.
Otherwise, subtract the positive integer from surplusValue.
Ex: If the input is:
then the output is:
is bad data The total after subtracting all positive values is
Note: The sentinel value is 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 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
