Thursday, December 8, 2011

How to use the "return" statement in Java?

For example:





there are 4 choices to choose from, choices are:





1. Withdraw


2. Deposit


3. Current Balance


4. Exit





For example the user pick 2(which is deposit), after the transaction, the program will then again make the user pick a transaction and this time the user pick 1(which is withdraw). What I'm getting at is I want the program to loop the process until the user picks 4(exit). How to do that?|||If you want to loop until the user enters option 4, then use a while loop around the entire menu process. Then call your functions. When the user picks 4, set a boolean variable to false and break out of the loop execution into the code that closes the program.|||Like SteveO said you can put enclose the menu options in a do while(because you want them to display at least once) and then set the loop condition to something like (menuOption != 4)

No comments:

Post a Comment