import java.util.Scanner;
public class CalAverage {
private Scanner scanner = new Scanner(System.in);
private int[] score = new int[10];
private int totalScore = 0;
private int num = 0;
private String s_scores;
private String[] s_score;
public CalAverage() {
System.out.print("请输入10个英语成绩(用空格隔开):");
s_scores = scanner.nextLine();
s_score = s_scores.split(" ");
for (int i = 0; i < s_score.length; i++) {
score[i] = Integer.parseInt(s_score[i]);
}
for (int i = 0; i < score.length; i++) {
totalScore += score[i];
if (score[i] < 60) {
num++;
}
}
System.out.println("10名学生平均分为:" + (totalScore / 10));
System.out.println("不及格的人数为:" + num);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new CalAverage();
}
}
运行结果