title: Reading a text file of student names and text scores and finding an average
body: <p>Currently I have text file that stores student names and their test scores. The format of the file is last name, first name, and test score. Each value in the text file is separated but a space. So the file looks similar to this:</p>
  
  <pre><code>Smith John 85
  Swan Emma 75
  </code></pre>
  
  <p>I've got the code running so that it prints all the data to the console, but what I can't get it to do is take all the test scores, add them up, and find the average and print the average to the console. As well as print any students' whose score is 10 less then the average.</p>
  
  <p>Right now this is the code I'm using to read and print the information to the console.</p>
  
  <pre><code>public class ReadTXT 
  {
  
  public static void main(String[] args) 
  {
  
  {
      String txtFile = "/Users/Amanda/Desktop/Studentdata.txt";
  BufferedReader br = null;
  String line = "";
  String txtSplitBy = " ";
  
      try {
  
      br = new BufferedReader(new FileReader(txtFile));
      while ((line = br.readLine()) != null) {
  
  
          String[] LastName= line.split(txtSplitBy);
                      String[] FirstName = line.split(txtSplitBy);
                      String[] TS = line.split(txtSplitBy);
  
          System.out.println("Last Name: " + LastName[0] 
                               + "\n" +"First Name: " + FirstName[1] + "\n" + 
                              "Test Score: " + TS [2] + "\n") ;
  
      {
          double average = sum / i;
      }
      }
      } catch (FileNotFoundException e) {
      e.printStackTrace();
  } catch (IOException e) {
      e.printStackTrace();
  } finally {
      if (br != null) {
          try {
              br.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  
  System.out.println("Done");
  
     }
  
    }
    }
  </code></pre>
  
  <p>And this is the code I was trying to use to find the average.</p>
  
  <pre><code> int i =Integer.parseInt ("TS");
  double sum = 0.0;
  for (int x = 0; x &lt; i; sum += i++);
  {
  double average = sum / i;
  }
  </code></pre>
  
  <p>I keep getting this exception, though:</p>
  
  <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "TS"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:492)
      at java.lang.Integer.parseInt(Integer.java:527)
      at ReadTXT.main(ReadTXT.java:35)
  </code></pre>
  
  <p>I am new to learning java but I am trying.</p>