/**
 * Third homework assignment, CMSC 10200, June 2005.
 *
 * @author <your name here>
 */

public class HW3 {

    /* Here's a sample function: mean. */

    /**
     * The function mean returns the arithmetic mean of an array of
     * integers.
     */
    static double mean(int[] ns) {
	int L = ns.length;
	if (L == 0) {
	    throw new IllegalArgumentException("empty array passed to 'mean'");
	}
	int sum = 0;
	for (int i=0; i<L; i=i+1) {
	    sum = sum + ns[i];
	}
	return ((double)sum) / L;
    }

    /* Write your own functions in this space. */






    /* Write tests inside the main function below. */

    public static void main(String[] args) {

	/* Here is an integer array for use in tests: */
	int[] integerArray = {1,2,3,4,5,6};

	/* you can declare an array of booleans similarly */
	
	/* here is a greeting... */
	System.out.println();
	System.out.println("Computer Science 102: Homework 3");
	System.out.println();

	/* A test of the mean function: */
	System.out.print("computing the mean of 1 through 6: ");
	System.out.println(mean(integerArray));

	System.out.println();

    }
}
