// Reads and prints the average of numbers read in from the file whose name is obtained from the user at the keyboard. End-of-file is used to 
// determine when to stop reading numbers.

import java.io.*;
import java.util.*;

public class Averager {
	public static void main(String [] args) throws Exception {
		Scanner keyboard = new Scanner(System.in);
		System.out.print("File name? "); 	// prompt
		String filename = keyboard.next();

		Scanner scanner = new Scanner(new File(filename));

		int total = 0;
		int count = 0;

		while (scanner.hasNextInt()) {
			int num = scanner.nextInt();
			total += num;
			count++;
		}

		System.out.println("The average of the numbers read in is: " + total/(double)count);
	}
}
