title: at java.util.Scanner.throwFor(Unknown Source) error
body: <pre><code>  private static int posNum() {
              Scanner scan = new Scanner(System.in);
              int input = 0;
              boolean error;
  
              if (scan.hasNextInt()) {
                  input = scan.nextInt();
                  error = input &lt;= 0;
              } else {
      28          scan.next();
                  error = true;
              }
              while (error) {
                  System.out.print("Invalid input. Please reenter: ");
                  if (scan.hasNextInt()) {
                      input = scan.nextInt();
                      error = input &lt;= 0;
                  } else {
                      scan.next();
                      error = true;
                  }
              }
              scan.close();
              return input;
  
          }
  </code></pre>
  
  <p>So the second time I call this method its returning the following error. </p>
  
  <pre><code>Exception in thread "main" java.util.NoSuchElementException
      at java.util.Scanner.throwFor(Unknown Source)
      at java.util.Scanner.next(Unknown Source)
      at q2.CylinderStats.posNum(CylinderStats.java:28)
      at q2.CylinderStats.main(CylinderStats.java:62)
  </code></pre>
  
  <p>The first call is <code>rad = posNum();</code> which runs fine and then secondis <code>height = posNum();</code> which doesn't allow a value to be entered before it goes to the error.</p>
  
  <p>Thanks</p>