/********************************************************************* * Author: Eric Heim * Date Created: 6/16/2011 * Course: CS0007 * Description: Shows how to find the average of the elements in * an array *********************************************************************/ public class ArrayAverage { public static void main(String[] args) { int[] myArray = {49, 99, 23, 54, 7, 16, 82}; double average = 0; for(int number : myArray) { average += number; } average /= myArray.length; System.out.println("The average of the elements in the array is: " + average); } }