Answer:
Written in Java
public static double average(double[] x){
double sum = 0.0;
for(int i=0;i<x.length;i++){
sum+=x[i];
}
return sum/x.length;
}
Explanation:
This defines the method
public static double average(double[] x){
This initializes sum to 0.0
double sum = 0.0;
This iterates through the array
for(int i=0;i<x.length;i++){
This adds up items of the array
sum+=x[i];
}
This returns the average
return sum/x.length;
}
Attached to this program is the full program that include the main method of the program