Question 1 10 points Write a method that computes the averag
Question 1 (10 points)
Write a method that computes the average of the values in an array of doubles.
The header of the method is as follows:
 
 public static double average(double[] x)
Solution
public static double average(double[] x)
{
 double sum = 0;
 for(int i = 0; i < x.length; i++) //loop runs the length of array(of type double) times
{
 sum += x[i];
 }
 return sum / x.length;
 }

