public static double average(double A[]) { double sum = 0; int n = 0; while(n < A.length) { sum = sum + A[n]; n++; } return sum/(A.length); }