Java Reference
In-Depth Information
This project expands on the Java help system that was created in
Try This 3-1
.
This version
adds the syntax for the
for
,
while
, and
do
-
while
loops. It also checks the user's menu se-
lection, looping until a valid response is entered.
1.
Copy
Help.java
to a new file called
Help2.java
.
2.
Change the first part of
main( )
so that it uses a loop to display the choices, as shown
here:
Notice that a nested
do
-
while
loop is used to discard any unwanted characters re-
maining in the input buffer. After making this change, the program will loop, display-
ing the menu until the user enters a response that is between 1 and 5.