Discuss about differences between while loop do-while loop


1. Provide your own short Java code example that uses a For or While loop. Be sure to test and describe what your code is doing. Use Java comments to document your code.

2. Discuss about differences between while loop, do-while loop and for loop. How transform while loop be transformed into a for loop, and vice versa? To understand better the loop statements design and implement an application that reads two integers values (initialNumber and finalNumber) and prints the sum of all even integers between initialNumber and finalNumber, inclusive.

Write three version of program.

For the first version use while loop

For the second version use do-while loop

For the third version use for loop

3. Discuss how we can implement an indefinite loop. Design and implement an application that reads a series of positive integer values from the user, sum them up, and computes their average. In this program we use a negative value to be a sentinel value that indicates the end of the input.

Solution Preview :

Prepared by a verified Expert
Business Management: Discuss about differences between while loop do-while loop
Reference No:- TGS01677465

Now Priced at $30 (50% Discount)

Recommended (93%)

Rated (4.5/5)