import java.util.Arrays;
public class TQC204
{
public static void main(String args[])
{
int score[];
int tmp=0 , sum=0 , pass=0, max=0, min=Integer.parseInt(args[0]);
double avg = 0.0;
int amt = args.length;
score = new int[amt];
for(int i = 0 ; i<amt ; i++ )
{
tmp = Integer.parseInt( args[i] );
score[i] = tmp;
sum += tmp;
max=Math.max(max,tmp);
min=Math.min(min,tmp);
if(tmp>=60)
pass++;
}
avg=(double)sum/amt;
/* use Arrays.sort to replace line 19,20ß
Arrays.sort(score);
max = score[amt-1];
min = score[0];
*/
System.out.println("===向日葵小班期末考風雲榜===\n");
System.out.println(" 本班最高分數是:"+max);
System.out.println(" 本班最低分數是:"+min);
System.out.println(" 本班及格人數有"+ pass +"人60分以上");
System.out.printf(" 本班期末考總平均是:%.2f\n", avg );
}
} |