title: Mutliple scanners for a program for class, I can't figure out how to have more than one
body: <p>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 &quot;Exception in thread &quot;main&quot; java.util.NoSuchElementException.&quot; 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.</p>
  <p>Shortened for the first scanner:</p>
  <pre><code>System.out.println();
  Scanner keyboard = new Scanner(System.in);
  System.out.println(&quot;Enter an integer: &quot;);
  int number = keyboard.nextInt();
  System.out.println(&quot;You entered: &quot; + number);
  keyboard.close();
  </code></pre>
  <p>Shortened code for the second scanner:</p>
  <pre><code>System.out.println();
  Scanner scanObj = new Scanner(System.in);
  System.out.println(&quot;Enter a number: &quot;);
  int id = scanObj.nextInt();
  System.out.println(&quot;You entered &quot; + id);
  scanObj.close();
  </code></pre>
  <p>DISCLAIMER: I know both scanners are doing the same thing, it's just example code that I typed up for my question.</p>