发布网友 发布时间:2024-10-23 22:12
共1个回答
热心网友 时间:2024-10-31 14:12
import java.util.*;
public class Yugi{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
while(true){
System.out.println("录入班级人数:");
int count = scan.nextInt();
int tmp = count;
System.out.println("录入各个学生的成绩: ");
double sum = 0;
while(tmp > 0){
double score = scan.nextDouble();
sum += score;
tmp--;
}
scan.close();
double avg = sum / count;
System.out.printf("平均成绩是:%.2f", avg);
break;
}
}
}