So I have this program, that is asking the user to enter whether he wants to continue or not, but my problem is, that the while
is misbehaving, and it is not waiting for the user input, instead repeats the loop without waiting for the scanner input at the bottom.
public static void main(String[] args) {
IO init = new IO();
Scanner scan = init.getScanner();
String exit = null;
do {
System.out.println("Your price");
int price = scan.nextInt();
int choice;
do {
System.out.println("VAT ");
System.out.println("1 = 5%");
System.out.println("2 = 15%");
System.out.println("3 = 0%");
choice = scan.nextInt();
} while (choice==0 || choice>3);
sazba saz = new sazba(choice);
double priceVAT = (double)price * saz.sazbaDPH();
System.out.println("Final price with VAT is: " +priceVAT);
System.out.println("Continue YES/NO");
exit = scan.nextLine();
} while (!exit.equalsIgnoreCase("no"));
}
I don't see any issue with my do-while
logic, but the compiler has some issues with it for some reason.