title: Find Average of numbers using a Text File in Java
body: <pre><code>package txtfileaverage;
  
  import java.io.*;
  import java.util.Scanner;
  
  /**
   *
   * @author Frazer
   */
  public class Txtfile {
  
      public static void main(String args[])  throws IOException
       {
          Scanner file = new Scanner(new File("input.txt")); 
  
          int numTimes = file.nextInt();
          file.nextLine();
  
              for(int i = 0; i &lt; numTimes; i++);
              {   
                  int sum = 0;
                  int count = 0;
                Scanner split = new Scanner(file.nextLine());
                while(split.hasNextInt())
                  //for (int a = 0; a &lt; 4 ; a++)
                  {
          sum += split.nextInt();
          count++;
                  }    
          System.out.println("the average is = " + ((double)sum / count));
  
              }
                  }
  
  }
  </code></pre>
  
  <p>Text File:</p>
  
  <pre><code>4
  
  100 100 100 100
  
  100 100 50  50
  
  100 90  80  70
  
  60  50  40  30 
  </code></pre>
  
  <p>the above is the text file i am trying to read from, the output that is displayed is </p>
  
  <p>"the average is 100" but it either only looks at one number or 1 line, any tips on how to get it to read the other lines? i have had a look at some tutorial and after comparing the code i'm struggling to find out why it's only finding the average of 1 number or 1 line rather than the whole row, each with another statement.</p>