// Arup Guha
// 2/4/2017
// Solution to AP Review Problem: Test Statistics

import java.util.*;

public class stats {
	
	public static void main(String[] args) {
		
		// Store socres here.
		ArrayList<Integer> scores = new ArrayList<Integer>();
		
		// Get user input.
		Scanner stdin = new Scanner(System.in);
		System.out.println("Please enter your test scores. Terminate the list with a -1.");
		int item = stdin.nextInt();
		while (item != -1) {
			scores.add(item);
			item = stdin.nextInt();
		}
		
		// Output all results.
		System.out.println("The class average was "+average(scores));
		System.out.println("The minimum score was "+min(scores));
		System.out.println("The maximum score was "+max(scores));
		System.out.println("The standard deviation was "+stdev(scores));
	}
	
	// Returns the average of the itesm in list.
	public static double average(ArrayList<Integer> list) {
		
		// Add everything up.
		int sum = 0;
		for (int i=0; i<list.size(); i++)
			sum += list.get(i);
			
		// Just divide by list size.
		return (double)sum/list.size();
	}
	
	public static double min(ArrayList<Integer> list) {
		
		// Initial min is first item.
		int res = list.get(0);
		
		// If you ever see anything better, update our min.
		for (int i=1; i<list.size(); i++)
			if (list.get(i) < res)
				res = list.get(i);
		return res;
	}
	
	public static double max(ArrayList<Integer> list) {
		
		// Initial max is first value.
		int res = list.get(0);
		
		// If you ever see anything better, update our max.
		for (int i=1; i<list.size(); i++)
			if (list.get(i) > res)
				res = list.get(i);
		return res;
	}
	
	public static double stdev(ArrayList<Integer> list) {
		
		// Get the average first.
		double avg = average(list);
		
		// Add the appropriate sum of squares.
		double sum = 0;
		for (int i=0; i<list.size(); i++)
			sum += Math.pow(avg-list.get(i),2);
			
		// Divide by list size then square root and return.
		sum /= list.size();
		return Math.sqrt(sum);
	}		
		
}