I am supposed to get the product of the integer entered by user util a number that is less than 1 is entered, and print the product. But when the program does nothing after I enter the numbers. How can I fix this.
Here is the code:
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter integers: ");
int num = 1;
int product = 1;
while(input.hasNextInt() && num>=0){
num = input.nextInt(); product = product*num;
}
System.out.print("Product: "+product);
}