Do while exercises
Lec4 – do while loop exercises
Create a new class called DoWhileLoops
- In a method called largestNumberOf5(), determine the largest number in a sequence of fixed size of 5.
Enter a number : 1
Enter a number : 1
Enter a number : 2
Enter a number : 3
Enter a number : 4
Largest is 4
- In a method called squares(), use a "do-while" loop to go from 1 to 5. In the loop, output the square of each value and total the sum of the squares
1
4
9
16
25
Total is 55
- In a method called doWhilecontinue(), code a while loop that prints all the numbers from 1 to 10 with the exception of the number 7, by using a continue.
1
2
3
4
5
6
8
9
10