I’m brand new to Java. Just started a class two weeks ago. I’m trying to get this small piece of code to recognize there will be no more input from the user. The book says type Ctrl Z to tell the program there will be no more input. Nothing happens except my computer just beeps as in an error occurred. To clarify, I’m not typing “Ctrl Z” into the line input. I’m hitting the CTRL key and Z key simultaneously. Here’s the code:
import java.util.Scanner;
public class Grade{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int gradeInput;
while (input.hasNext()) {
gradeInput = input.nextInt();
System.out.printf(“%dn”,gradeInput);
} //end while
} //end main
} //end class