import java.io.File;
import java.util.Scanner;
import java.util.ArrayList;


public class Question2 {

	public static void main(String[] args) {
		
		// Instantiate File and Scanner objects
		File foobar;
		Scanner input;
		
		// Setup file
		foobar = new File ("files\\Question2.txt");
		
		// Read file
		try {
			
			// Set up Scanner
			input = new Scanner(foobar);
			
			// Setup variables
			String courseCode;
			int studentCount = 0, markTotal = 0;
			
			// Reader assumes that the file is in the correct format
				// Course code
				courseCode = input.nextLine();
				// Tally up marks and student count
				while (input.hasNextInt()) {
					markTotal+=input.nextInt();
					studentCount++;
				}
			
			// Clean up
			input.close();
				
			// Report results
			System.out.println("The average for the course "
					+ courseCode
					+ " is "
					+ markTotal/studentCount
					+ "."
					);
			
		} catch (java.io.FileNotFoundException e) {
			
			// From "input = new Scanner(foobar);"
			System.err.println("Error: file " + foobar + " not found.");
			e.getMessage();
			System.exit(1);
		}

	}

}
