title: There's an InputMismatchException, how do i fix it?
body: <p>The question is to output the total salary and average salary of each rank,
  this is my code:</p>
  <pre><code>     URL url=new URL(&quot;http://liveexample.pearsoncmg.com/data/Salary.txt&quot;);
          Scanner input=new Scanner(url.openStream());
          String[]FirstName=new String[1000];
          String[]LastName=new String[1000];
          String[]rank=new String[1000];
          int[]salary=new int[1000];
          
          int i=0;
          int count=0;
          double sum=0;
          while(input.hasNext()) {
              FirstName[i]=input.nextLine();
              LastName[i]=input.nextLine();
              rank[i]=input.nextLine();
              salary[i]=input.nextInt();
              if(rank[i]==&quot;assistant&quot;) {
                  count++;
                  sum+=salary[i];
                  System.out.print(&quot;Total salary of assistant professors:&quot;+sum+&quot; average: &quot;+sum/count);
              }
              else if(rank[i]==&quot;associate&quot;) {
                  count++;
                  sum+=salary[i];
                  System.out.print(&quot;Total salary of associate professors:&quot;+sum+&quot; average: &quot;+sum/count);
              }
              else if(rank[i]==&quot;full&quot;) {
                  count++;
                  sum+=salary[i];
                  System.out.print(&quot;Total salary of full professors:&quot;+sum+&quot; average: &quot;+sum/count);
              }
              else if(rank[i]==&quot;faculty&quot;) {
                  count++;
                  sum+=salary[i];
                  System.out.print(&quot;Total salary of faculty professors:&quot;+sum+&quot; average: &quot;+sum/count);
              }
              input.close();
          }
  </code></pre>
  <p>however the output is InputMismatchException,and i checked my code many times, i can't find the error</p>
  <pre><code>Exception in thread &quot;main&quot; java.util.InputMismatchException
      at java.base/java.util.Scanner.throwFor(Scanner.java:939)
      at java.base/java.util.Scanner.next(Scanner.java:1594)
      at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
      at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
      at HW11_09156136.HW11_09156136_01.main(HW11_09156136_01.java:24)
  </code></pre>