Average an array program

The problem

Write two overloaded methods that return the average of an array with the following headers: public static int average(int[] array) public static double average(double[] array). Write a test program that prompts the user to enter ten double values, invokes this method, and displays the average value.

Breaking it down

Swaying a bit from the requirements the program will still ask for the user to input ten numbers. Instead of writing an imperative methods to calculate the mean of an array we will use java 8 to do so.

static final int SIZE = 10;

public static void main(String[] args) {

    double[] numbers = new double[SIZE];
    Scanner input = new Scanner(System.in);
    System.out.print("Enter 10 double numbers: ");
    for (int i = 0; i < numbers.length; i++) {
        numbers[i] = input.nextDouble();
    }
    input.close();

    System.out.println("The average value is: "
            + Arrays.stream(numbers).average().getAsDouble());

}

Output

Enter 10 double numbers: 9
8
8
6
4
5
4
56
6
6
The average value is: 11.2