// Write a method which is passed the name of a text file which
// contains grades in a course that's in the following format:

// Stan 99 87 100
// Dipper 100 100 97 100
// Mabel 100 100
// Seuss 72 85 65

// the method returns the average of the student with the highest semester average.

public static double highAvg(String filename) {
  Scanner in = new Scanner(new File(filename));
  double highestSoFar = -1.0;

  while (in.hasNextLine()) {
    /* get the next avg */
    double cur = calcAvg(in.nextLine());
    
    if (cur > highestSoFar) {
      highestSoFar = cur;
    }
  }
  
  return highestSoFar;
}

// given a line that looks like this: Stan 99 87 100
//     returns the average
public static double calcAvg(String line) {
  Scanner in = new Scanner(line);
  String name = in.next();

  double sum = 0.0;
  int count = 0;

  while (in.hasNextDouble()) {
    sum += in.nextDouble();
    count++;
  }
  return sum / count;
}

// |--------------+-----------------|
// | next()       | hasNext()       |
// | nextLine()   | hasNextLine()   |
// | nextInt()    | hasNextInt()    |
// | nextDouble() | hasNextDouble() |
// |--------------+-----------------|
