title: Why am I getting InputMismatchException?
body: <p>So far I have this:</p>
  
  <pre><code>public double checkValueWithin(int min, int max) {
      double num;
      Scanner reader = new Scanner(System.in);
      num = reader.nextDouble();                         
      while (num &lt; min || num &gt; max) {                 
          System.out.print("Invalid. Re-enter number: "); 
          num = reader.nextDouble();                         
      }
      return num;
  }
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>public void askForMarks() {
      double marks[] = new double[student];
      int index = 0;
      Scanner reader = new Scanner(System.in);
      while (index &lt; student) {
          System.out.print("Please enter a mark (0..30): ");
          marks[index] = (double) checkValueWithin(0, 30); 
          index++;
      }
  }
  </code></pre>
  
  <p>When I test this, it can't take double number and I got this message:</p>
  
  <pre><code>Exception in thread "main" java.util.InputMismatchException
  at java.util.Scanner.throwFor(Scanner.java:909)
  at java.util.Scanner.next(Scanner.java:1530)
  at java.util.Scanner.nextDouble(Scanner.java:2456)
  at MarkingSystem.checkValueWithin(MarkingSystem.java:25)
  at MarkingSystem.askForMarks(MarkingSystem.java:44)
  at World.main(World.java:6)
  Java Result: 1
  </code></pre>
  
  <p>How do I fix this?</p>