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

class Apr20 {

	public static void main(String[] args) {

		// Assume a file named grades.txt has a decimal number on each line.
		// Sum up the values in the file and print the sum to the screen.

		Scanner input = null;
	
		try {
			input = new Scanner(new File("grades.txt"));
		}
		catch (FileNotFoundException e) {
			System.out.println("File not found");
			return;
		}	

		double sum = 0.0;
		while(input.hasNext()) {
			sum += input.nextDouble();
		}
		System.out.println("sum: " + sum);
		input.close();
		
		// Assume a file named grades.txt has a decimal number on each line.
		// Store the values in the file in an array, then print the contents of the array.
		try {
			input = new Scanner(new File("grades.txt"));
		}
		catch (FileNotFoundException e) {
			System.out.println("File not found");
			return;
		}	

		int counter = 0;
		while(input.hasNext()) {
			input.nextDouble();
			counter++;
		}

		input.close();

		try {
			input = new Scanner(new File("grades.txt"));
		}
		catch (FileNotFoundException e) {
			System.out.println("File not found");
			return;
		}	
		
		double[] numbers = new double[counter];

		for(int i = 0; i < counter; i++) {	
			numbers[i] = input.nextDouble();
		}

		for(double d : numbers) {
			System.out.print(d + " ");
		}
		System.out.println();



	}
	
}
