title: java.util.InputMismatchException in my integer validation method
body: <p>I get java.util.InputMismatchException every time a letter is entered. I'd like it to display the "incorrect message" instead of crashing. I tried making x a string and parsing the input, but the problem was still the same. Not quite sure how to do this. Here is my code: </p>
  
  <pre><code>public static void generateDivision() {
  
      Random rand4 = new Random();
      Scanner keyboard6 = new Scanner(System.in);
  
      int random = rand4.nextInt(12);
      int random2 = rand4.nextInt(12);
  
      //Following two lines ensures that no remainders are present so the numbers divide evenly.
      int n = random * random2;               
      int k  = n/random;                 
  
      System.out.println(n + " / " + random + " = ?");
      int x = keyboard6.nextInt();
  
      checkUserAnswer(k, x);
  }   
  public static void checkUserAnswer(int n, int x) {
  
      try {
          if (n == x) {
  
              System.out.println("Correct!");
              System.out.println();
  
  
          }
          if (n != x) {
  
              System.out.println("Incorrect!");
              System.out.println();
  
  
          }
      } catch (InputMismatchException e) {
          System.out.println("Incorrect! That was not a number.");
  
      } 
      updateStats(n, x);
      tryAgain();
  
      }
  </code></pre>