public class Test{
public static void main(String args[]){
int array[] = new int[5];
array[0] = 10;
array[1] = 5;
array[2] = 2;
array[3] = 4;
array[4] = 9;
System.out.println("average="+average(array));
}
public static int average(int[] array){
int total = 0;
for( int i = 0 ; i < array.length ; i++ )
total += array[i];
return total / array.length;
}
}
|