import type.lang.*;

public class Example12d
{
	public static void main(String[] args)
	{
		// As before, except reading the integers from a file and using the 
		// “end of file” (eof) marker as the sentinel.  (text, p. 131)
		UniReader ur = new UniReader("data.txt");
		final int SENTINEL = -1;

		int count = 0;
		int sum = 0;

		IO.println("Reading integers from 'data.txt' ... ");
		int num = ur.readInt();
		int max = num;
		for (; !ur.eof(); num = ur.readInt())
		{
			++count;
			sum += num;
			if (num > max)
				max = num;
		}
		double average = (double)sum / count;
		IO.println("count: " + count);
		IO.println("sum: " + sum);
		IO.println("average: " + average);
		IO.println("max: " + max);
	}
}
