发布网友 发布时间:2022-04-26 01:21
共1个回答
热心网友 时间:2022-06-19 09:54
package test;
import java.util.Scanner;
public class Homework {
private static int yx,lh,zd,jg,bjg;
public static void main(String[] args) {
String ff = "";
Scanner s = new Scanner(System.in);
int num = 0;
String flag ;
while(num < 20){
flag = s.nextLine();
if(flag.equals("")){
break;
}
ff = ff + flag + "-";
num ++;
}
int count = ff.split("-").length;
double sum = 0;
int avg = 0;
for(int i=0;i<count;i++){
sum = sum + Double.valueOf((ff.split("-")[i]) );
level(Double.valueOf((ff.split("-")[i])));
}
avg = (int) sum / count;
System.out.println("总人数:"+count+"\n总分:"+sum+"\n平均分值:"+avg);
System.out.println("优秀:"+yx+"\n良好:"+lh+"\n中等:"+zd+"\n及格:"+jg+"\n不及格:"+bjg);
}
private static void level(double d){
if(d>=90){
yx ++;
}else if(d >=80){
lh ++;
}else if(d >=70){
zd ++;
}else if(d>=60){
jg ++;
}else {
bjg ++;
}
}
}