Hi,
Consider the following program:
try {
int choice = 0;
while (choice != 5) {
System.out.println(" 1 : push a onto b "
System.out.println(" 2 : push a over b "
System.out.println(" 3 : stack a onto b "
System.out.println(" 4 : stack a over b "
System.out.println(" 5 : quit "
choice = System.in.read();
System.out.println("choice :" + choice);
}
} catch (Exception e) {
System.out.println(" Error : " + e.getMessage());
}
The program accepts a number from the user, prints the entered number, and displays the menu again. Instead of the entered number being printed 3 new numbers are getting printed (with the menu)!! For example, if I enter 3, I get 51, (menu), 13, (menu), 10 !! Can anyone tell me why this is happening?
Regards.
Consider the following program:
try {
int choice = 0;
while (choice != 5) {
System.out.println(" 1 : push a onto b "
System.out.println(" 2 : push a over b "
System.out.println(" 3 : stack a onto b "
System.out.println(" 4 : stack a over b "
System.out.println(" 5 : quit "
choice = System.in.read();
System.out.println("choice :" + choice);
}
} catch (Exception e) {
System.out.println(" Error : " + e.getMessage());
}
The program accepts a number from the user, prints the entered number, and displays the menu again. Instead of the entered number being printed 3 new numbers are getting printed (with the menu)!! For example, if I enter 3, I get 51, (menu), 13, (menu), 10 !! Can anyone tell me why this is happening?
Regards.