title: Keep asking for user input until an integer is between two numbers
body: <p>I need help with the following code:</p>
  
  <pre><code>    int seatNum = 0;
  
      Scanner seatNumber = new Scanner(System.in);
  
      do
      {
          try 
          {
              System.out.println("Please choose a seat number");
              seatNum = seatNumber.nextInt();  
          } 
          catch(InputMismatchException e) 
          {
              System.out.println("The index you have entered is invalid");
              System.out.println("Please enter an index number between 0 and 7");
  
          }
  
      } while (seatNum &lt;= 0 || seatNum &gt;= 7);
  </code></pre>
  
  <p>Basically, all I want is for seatNum to be between 0 and 7 if not ask the user to input again. When I input an integer that's not between 0 and 7 everything works correctly but if I enter a String the program goes to an infinite loop. How do I stop the program of going into an infinite loop when the user inputs String?</p>