The function mean should take an array of numbers and compute their arithmetic mean. For example, given an array containing 50 and 40 then mean should return 45. Complete the implementation of this function.
The function mean should take an array of numbers and compute their arithmetic mean. For example, given an array containing 50 and 40 then mean should return 45. Complete the implementation of this function.
You can used java stream to calculate the avg.
public double getAverage(int[] arr) {
return Arrays.stream(arr).average().orElse(Double.NaN);
}