I am new to programming. This is my question:
- Write a method that returns the average of the array of integers.
- If the array is empty, method returns 0.
What I have done so far:
public double getAverage (int[] values) {
int sum = 0;
for(int i : values) sum += i;
return ((double) sum)/values.length;
}
Any one help me with the 2nd part please?