title: If user inserts character other than Integer, the program should give him another chance to write an integer
body: <p>Ok, im trying to stop a user from enterring values other than Integers and smaller than 3 (first case). So far i have this code and the problem is, i cant make it stop, until the user enters correct values. i want to stup it and make him insert an integer into variable n and then can continue to add a value into variable  a   . how should i do this?
  EDIT : new code</p>
  
  <pre><code>public class mnohouholnik  {
   public double a;
   public int n;
   public void main() {
       Scanner sc = new Scanner(System.in);
       boolean error = false;
  
  while ( ! error &amp;&amp; n&lt;3 ) { //you cant have a polygon which has only two angles
  
      try
      {
  
         System.out.println("Enter the number of angles in polygon");
          n = sc.nextInt();
  
          error = true;
  
  
  
  
      }
      catch(InputMismatchException e )
      { 
          System.out.println("Wrong value, try again");
          sc.nextLine();
  
  
      }
  
      try
      {
  
         System.out.println("Insert the length of the side :");
          a = sc.nextDouble();
          error = true;
  
  
  
      }
      catch(InputMismatchException e )
      { 
          System.out.println("Wrong value, try again");
          sc.nextLine();
  
  
      }
  } 
  </code></pre>
  
  <p>}</p>
  
  <p>}</p>