Q:

My program compiles, but it gives me a 0.0 average when there is no 0 in source file

I am working on an assignment, my program is supposed to read grades from a file and output an average.  My code compiles, but the output is always 0.0.
Code is as follows:
import java.util.Scanner;
import java.io.File;
import java.io.FileReader;
import java.io.FileNotFoundException;
public class testScores
{
   public static void main ( String [] args )
   {
      int i;
      int c;
     double [] testScores = new double[7];
      i=0;
   try
      {  
         Scanner scan = new Scanner( new File ( "testScores.txt") );
         while( scan.hasNext() )
         {
            String temp = scan.nextLine();
            testScores[i] = Double.parseDouble(temp);
            i++;
         }
         scan.close();
      }

      catch ( FileNotFoundException fnfe )
      {
         System.out.println("Unable to find the testScores.txt file.       Program terminating.");
      }

      catch (Exception e)
      {
          e.printStackTrace();
      }
   double avgStart = 0;
   double avgFinal;  
   int gradeCount = 1;    
      while ( i < testScores.length)
         {
           avgStart += testScores[i];
           i++;
         }  

    avgFinal = avgStart / i;

    System.out.println("The final average of all of the test scores in the file testScores.txt are " + avgFinal + ".");

   }
}

Please give any insight into it. I'am not sure how the code gets to zero.

A:

If you divide by an integer then your result will be an integer 
With integer division
1.0 / 2 == 0

so change 
avgFinal = avgStart / i;

to
avgFinal = avgStart / (double) i;

