import CSLib.*;
public class NumberList
{
	public static int average (int [] list)
	{
		int sum = 0;
		for (int k=0; k<list.length; k++)
		{
			sum = sum + list [k];
		}
		return sum / list.length;
	}
	
	public static void display (OutputBox box, int [] list)
	{
		for (int k=0; k<list.length; k++)
		{
			box.println (list [k]);
		}
		box.println ();  //double space
	}
	
	//The following calculates the standard deviation of list
	public static int sd (int [] list, int avg)
	{
		//lab exercise
		//HINT:  Copy and paste the code for average () from above and modify
		int sum = 0;
		for (int k=0; k<list.length; k++)
		{
			sum = sum + (list [k] - avg)*(list [k] - avg);
		}
		return (int)Math.sqrt (sum / list.length);
	}
	
	//The following method finds the smallest item in a list of integers
	public static int smallest (int [] list)
	{
		int smallestSoFar;
		
		//The following focuses on smallestSoFar,
		//a variable that is compared with each item
		//in the list in succession.  As smaller items
		//are encountered, they are assigned to the variable
		//smallestSoFar.
		smallestSoFar = list[0];
		for (int k=1; k<list.length; k++)
		{
			if (list[k] < smallestSoFar)
			{
				smallestSoFar = list[k];
			}
		}
		return smallestSoFar;
	}	
}
