aspose file tools*
The moose likes Beginning Java and the fly likes strange issue, program not terminating properly when returning from sub-menu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "strange issue, program not terminating properly when returning from sub-menu" Watch "strange issue, program not terminating properly when returning from sub-menu" New topic
Author

strange issue, program not terminating properly when returning from sub-menu

Randy Smith
Ranch Hand

Joined: Mar 27, 2011
Posts: 44

Hi! Thank you for looking. I have a console menu where the program terminates normally through switch statements in mainmenu but when returning to mainmenu from sub-menu, i have to enter "0" twice to terminate the program from mainmenu. I checked everywhere, and everything look fine. this is very strange... Here's the simplified code. Am I doing anything incorrently? Any assistance is appreciated!

mainMenu(){

do {
int option;
boolean terminate=false;

print welcome shopper's world!
print 1. Add item to cart
print 2. remove item from cart
print 3. view cart
print 0. quit

print Please make a selection:

new scanner input object

switch (option)

case 1: addItem();
break();

case 2: removeItem();
break();

case 3: viewCart();
break();

case 0: println("Thank you for your business!");
terminate=true;
break();

default: print invalid option, try again!
break();

}while (!terminate);
}

addItem(){

if(true){
//do something here...

}

else{
mainmenu();
}


}

Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
Please post code which actually compiles, otherwise any help would be pure guesswork. Instructions on how to reproduce error would also help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: strange issue, program not terminating properly when returning from sub-menu