Read the class notes on while loops (both pages). Read the section on break; continue;
Copy the program at the bottom of the while loop page 1 and run it.
Once you've done this, then ...
The second page on while loops (course notes) shows 4 ways of making and exiting while loops.
All four of your programs will do this:
Here's the outline of how to do the first program (using while (true){
)
while (true) { }
}
Example:
n total --------------- 2 2 4 6 20 6 (multiples of 5 are ignored) 11 17 6 17 (multiples of 3 are ignored) -99 17 (exit the loop) Total = 17
4 programs: There are four ways of writing and exiting While loops
Write 4 programs, each using one of the following forms of the while loop, and each one doing the same logic with %3, %5 and -99.
while(true)
and exiting using break
while( ..... ) {
while(keepLooping) {
You can call them While1.java, While2.java, While3.java and While4.java