/** @author CPSC 111 Jan 2010
 * @date 8 Mar 2010
 * Compute average, max, and create histogram.
 */
public class AverageArray {
	public static void main(String[] args) {
		int[] numbers = {6,8,11,18,50,17,14,10,5,2};
		int sum = 0;
		int max = 0;
		for (int i = 0; i < numbers.length; i++) {
			sum = sum+numbers[i];
			if (max < numbers[i]) {
				max = numbers[i];
			}
			//need a loop. for, while or do?
			for (int j = 0; j < numbers[i]; j++) {
				System.out.print("*");
			}
			System.out.println();
		}
		//sum /= numbers.length; // not so clean, changed meaning of variable
		// be careful to do real not integer arithmetic here!
		double avg = sum / (double) numbers.length;
		System.out.println("avg is "+avg+" max is "+max);
	}

}

