I need to make four scanners in a Java program for my CS1400 class. I was told to make each scanner have a different variable name, but doing that only made the program crash with an error reading "Exception in thread "main" java.util.NoSuchElementException." I'm not sure what I'm doing wrong, and it could be fairly simple. My Java and IntelliJ (required for the class) is all update.
Shortened for the first scanner:
System.out.println();
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter an integer: ");
int number = keyboard.nextInt();
System.out.println("You entered: " + number);
keyboard.close();
Shortened code for the second scanner:
System.out.println();
Scanner scanObj = new Scanner(System.in);
System.out.println("Enter a number: ");
int id = scanObj.nextInt();
System.out.println("You entered " + id);
scanObj.close();
DISCLAIMER: I know both scanners are doing the same thing, it's just example code that I typed up for my question.