Code: Select all
public double average(int[] values){
/* by the way, can you tell what will happen if sum is declared as int?
double sum = 0;
for(int i=0; i<values.length; i++) sum += values[i];
return values.length==0?0 : sum/values.length;
}