A "do-while" loop is traditionally used for this purpose. Can you identify which parts of the code you want to run again? That's the body of the loop. And how do you know you are done? (you probably want another option for "quit" so this doesn't go on forever)
1. user selects menu item (eg add book) (which i have)
2. the user inputs data requested via scanner class (which i have)
3. the data is displayed and user asked if they wish to submit.(which i have)
4. If yes, the data is stored (which i have) and the user is returned to the menu (which im stuck with)
5. If no, the user is returned to the menu (which im stuck with)
I agree that i need an exit button, which i have since found, but my brains given up on me
You're going to need a Do/While statement like another rancher said.... it'll look like this:
so the do before the while causes the loop to be done at least once. The user choice will let the JVM know if the user wants to exit. You could also ask the user if s/he'd like to keep going and reverse the logic if you like it that way....
Hope that helps
When you do things right, people won't be sure you've done anything at all.
System.out.println("\n press 1 for ... , 2 for .... 3for .... , 4 for EXIT");
case 1://do somthing...call a method...break;
case 2://..... berak;
case 3://...do some thing break;
case 3: system.exit(1);// or break;
defaule: System.out.println("\n Wrong Key Press TRy Again!");
posted 9 years ago
I have the following so far, but could do with some help to get the syntax correct.