This version adds the syntax of for, while and do-while loops. It also checks the user's selection in the menu, looping until a response
valid to be entered.
Copy Help.java into a new file called Help2.java
Change the first part of main( ) so that it uses a loop when displaying the options.
Note that a nested do-while loop is used to discard any unwanted characters remaining in the input buffer. After this change, the program will enter a loop, displaying the menu until the user enters an answer between 1 and 5.
Note that there is no default statement present in this switch version. Since the menu loop ensures that a valid response is entered, it is no longer necessary to include a default statement for handling a choice
invalid.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3