import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class $ {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
List<Double> data = new ArrayList<Double>();
while (true) {
System.out.println("输入成绩,退出:-1");
Double num = in.nextDouble();
if (num.intValue() == -1) {
break;
}
data.add(num);
}
System.out.println("总成绩:" + sum(data));
System.out.println("及格率:" + jige(data));
// 降序排序
Collections.sort(data, new Comparator<Double>() {
public int compare(Double o1, Double o2) {
return o2.compareTo(o1);
}
});
System.out.println("最高成绩:" + data.get(0));
for (Double d : data) {
System.out.println(d);
}
}
private static Double sum(List<Double> data) {
Double sum = 0.0;
for (Double d : data) {
sum += d;
}
return sum;
}
private static double jige(List<Double> data) {
double i = 0;
for (Double d : data) {
if (d >= 60) {
i++;
}
}
return i / data.size();
}
}
输入成绩,退出:-1
50
输入成绩,退出:-1
60
输入成绩,退出:-1
70
输入成绩,退出:-1
100
输入成绩,退出:-1
90
输入成绩,退出:-1
80
输入成绩,退出:-1
-1
总成绩:450.0
及格率:0.8333333333333334
最高成绩:100.0
100.0
90.0
80.0
70.0
60.0
50.0