Average of all elements in array - Java Quiz Question


Write a program to get the average of all elements in array.

Input (Integer Array) Output (Integer)
{2, 3, 4, 7, 9} (2 + 3 + 4 + 7 + 9) / 5 = 5
{3, 9, 1, 5, 14, 10} (3 + 9 + 1 + 5 + 14 + 10) / 6 = 7
{78, 32, 45, 17, 18, 63, 29} (78 + 32 + 45 + 17 + 18 + 63 + 29) / 7 = 40



class AverageOfArrayElements
{
    public static void main(String s[])
    {
        int[] input = {2, 3, 0, 2, 8};
        int average = getAverageOfArrayElements(input);
        System.out.println("Average of array is " + average);

    }


    public static int getAverageOfArrayElements(int[] array)
    {
        int result = 0;
    
        return result;
    }

}