title: Getting a type mismatch exception in my java code
body: <p>Getting error when reading the 3rd element. That is while pt variable from the terminal it is returning type mismatch error i cant seem to understand why cause i declared a string variable st and used nextLine() to read from the terminal</p>
  <pre><code> public static void main(String[] args) 
      {
          TravelAgencies[] ta = new TravelAgencies[4];
          Scanner s= new Scanner(System.in);
          for(int i=0;i&lt;4;++i)
          {
              int r=s.nextInt();
               System.out.println(r);
              String an=s.nextLine();
               System.out.println(an);
              String pt=s.nextLine();
               System.out.println(pt);
              int p=s.nextInt();
                System.out.println(p);
              boolean ff=s.nextBoolean();
               System.out.println(ff);
              ta[i]=new TravelAgencies(r, an, pt, p, ff);
          }
          int max=findAgencyWithHighestPackagePrice(ta);
          System.out.println(max);
          
          int regNo=s.nextInt();
          
          String pac=s.next();
          
          TravelAgencies rs=agencyDetailsForGivenIdAndType(ta,regNo,pac);
          if(rs!=null)
          {
              System.out.println(rs.agencyName+&quot;\n&quot;+rs.price);
          }
          else
          System.out.println(rs);
          s.close();
          
      }
  </code></pre>
  <pre><code>error
  123
  123
  
  abhi
  abhi
  agency
  Exception in thread &quot;main&quot; java.util.InputMismatchException
      at java.util.Scanner.throwFor(Unknown Source)
      at java.util.Scanner.next(Unknown Source)
      at java.util.Scanner.nextInt(Unknown Source)
      at java.util.Scanner.nextInt(Unknown Source)
      at Probsolving.Solution.main(Solution.java:19)
  </code></pre>