## CS 1401 Introduction to Computer Science Fall 2014, Lab 8

Motivation: to practice arrays.

Background. Often, we know several values x1, ..., xn of a certain quantity: e.g., we know the outside temperature on different days in October. It is frequently useful to find:

• the smallest of these values (e.g., the coldest temperature),
• the largest of these values (e.g., the warmest temperature);
• the average a of these values (e.g., the average temperature in October);
• the mean deviation, i.e., the average value of the quantity |a − xi|;
• the standard deviation, i.e., the square root √s, where s is the average value of the quantity (a − xi)2.

Assignment. Write a program for simple statistical analysis of the data. Your program should contain the following methods:

• an input method; this method should ask the user for a number of inputs, declare an array of the corresponding size, then ask the user for the values x1, ..., xn and place these values into an array;
• a method for computing the smallest element of a given array;
• a method for computing the largest element of a given array;
• a method for computing the average of a given array;
• a method for computing the mean deviation: this method should take the given array, use the mean method to compute its mean, generate the new array of quantities |a − xi|, and use the mean method again to compute the mean difference;
• a method for computing the standard deviation: this method should take the given array, use the mean method to compute its mean, generate the new array of quantities (a − xi)2, use the mean method again to compute the mean value of this quantity, and then take the square root.
When it is due. The program with the first four methods are due at the beginning of the first lab section on the week of November 3, i.e.:
• on Monday November 3 for those who attend Monday-Wednesday labs, and
• on Tuesday November 4 for those who attend Tuesday-Thursday labs.
The full program is due at the beginning of the second lab section on the week of November 3, i.e.:
• on Wednesday November 5 for those who attend Monday-Wednesday labs, and
• on Thursday November 6 for those who attend Tuesday-Thursday labs.