why did this worked:
do{
System.out.println("\nWhich food or beverage would you like to order? ");
int OrderNum;
OrderNum = scan.nextInt();
switch(OrderNum){
case 1:
System.out.println("\nHow many quanitites would you like to order?");
NasiAyamPenyet.quantity = scan.nextInt();
break;
case 2:
System.out.println("\nHow many quanitites would you like to order?");
NasiKukus.quantity = scan.nextInt();
break;
case 3:
System.out.println("\nHow many quanitites would you like to order?");
NasiAyamHainan.quantity = scan.nextInt();
break;
}
System.out.println("\nWould you like to order more?");
i = scan.nextInt();
}
while(i<2);
But the loop will ignore the string input in this one, there is only little difference in the code, I changed it so the user inputs a yes and no line that will then be converted back to the original code. I don't understand why it wouldn't work :
do{
System.out.println("\nWhich food or beverage would you like to order? ");
int OrderNum;
OrderNum = scan.nextInt();
switch(OrderNum){
case 1:
System.out.println("\nHow many quanitites would you like to order?");
NasiAyamPenyet.quantity = scan.nextInt();
break;
case 2:
System.out.println("\nHow many quanitites would you like to order?");
NasiKukus.quantity = scan.nextInt();
break;
case 3:
System.out.println("\nHow many quanitites would you like to order?");
NasiAyamHainan.quantity = scan.nextInt();
break;
}
System.out.println("\nWould you like to order more?");
ans = scan.nextLine();
if(ans.equals("yes")){
i = 1;
}
else if(ans.equals("no")){
i=2;
}
}
while(i<2);