import java.util.Scanner;
//import java.io.*;    // File, FileNotFound, ...

public class AverageMonthlyTemperatures {
	public static void main(String[] args) {
		System.out.println("To average a month's temperatures,");
		Scanner fin = FileOps.promptForFileIn("enter the input file: ");
		Temperature temp = new Temperature();
		double sum = 0.0;
		int count = 0;
		while ( fin.hasNext() ) {
			temp.read(fin);
			sum += temp.inCelsius().getMagnitude();
			count++;
		}
		fin.close();
		if (count > 0) {
			System.out.println("The average temperature is "
					           + new Temperature(sum/count, 'C') );
		} else {
			System.err.println("No values in input file!");
		}
	}
}
