The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
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.
Â
Example
Enter
Enter
Sum of the even integers between 1 to 19 +4+6+8+10+12+14+16+
Â
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.
Â
Example
Enter an integer (0 to quit): 1
The sum so far is 1
Enter an integer (0 to quit): 2
The sum so far is 3
Enter an integer (0 to quit): 3
The sum so far is 6
Enter an integer (0 to quit): 4
The sum so far is 10
Enter an integer (0 to quit): 5
The sum so far is 15
Enter an integer (0 to quit): 6
The sum so far is 21
Enter an integer (0 to quit): 0
Â
The average is 3.5
Â
-----------