Hello,
I have a problem while reading 3 integers in each line of which I don't know the number of. The problem I have is with the last line of integers. It simply refuses to print out and the program doesn't stop running. Here is my code:
I test it by pasting the following numbers
but it doesn't print out 50 4 1...
What could be the problem?
I have a problem while reading 3 integers in each line of which I don't know the number of. The problem I have is with the last line of integers. It simply refuses to print out and the program doesn't stop running. Here is my code:
Code:
import java.util.Scanner;
public class Restaurant {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int money = sc.nextInt();
while(sc.hasNextInt()){
int price = sc.nextInt();
int quantity = sc.nextInt();
int wine = sc.nextInt();
System.out.println(price+" "+quantity+" "+wine);
}
}
}
I test it by pasting the following numbers
Code:
500 30 5 0 30 6 1 15 5 1 20 7 0 50 4 1
What could be the problem?
Comment