Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use do-while loop to Writes a program in java that reads and calculates the sum of an unspecified number of integers. The input 0 signifies

Use do-while loop to Writes a program in java that reads and calculates the sum of an unspecified number of integers. The input 0 signifies the end of the input.

Do you need to declare a new variable for each input value? No.

Just use one variable named data to store the input value and use a variable named sum to store the total.

Whenever a value is read, assign it to data and, if it is not zero, add it to sum

Sample input:

Enter an integer (the input ends if it is 0): 2

Enter an integer (the input ends if it is 0): 3

Enter an integer (the input ends if it is 0): 4

Enter an integer (the input ends if it is 0): 0

Sample output:

The sum is 9

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

=+Are there shop stewards?

Answered: 1 week ago