Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - JAVA programming. Define an integer array containing 10 elements, find the average and maximum value of this 10 number, and print it out on the screen.
JAVA programming. Define an integer array containing 10 elements, find the average and maximum value of this 10 number, and print it out on the screen.
Public void tt(){

int test[]=new int[]{4,2, 1,5, 1,6,2,6,23,98 };

int max = 0;

int sum = 0;

for(int I = 0; I < test the length; i++){

if(test[I]& gt; Max) {

max = test[I];

}

sum+= test[I];

}

system . out . println(" max "+max);

system . out . println(" and "+sum);

system . out . println(" average "+(float)sum/(float)test . length);

}