Observations on the program of example 3.2
The program of example 3.2 uses the break statement to exit from the while loop. The the break statement is very handy but it deviates from the rules of structured programming. When you learned to program in Java you followed the rules of structured programming. If you want to rewrite the program of assignment 3.2 following the rules of structured programming and without using the break statement, these are two possible ways: