import java.util.Scanner;

public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int[] scores = new int[5]; int sum = 0; int count = 0; for (int i = 0; i < 5; i++) { System.out.print("请输入第" + (i+1) + "个同学的成绩: "); scores[i] = scanner.nextInt(); sum += scores[i]; if (scores[i] >= 80) { count++; } } double average = (double)sum / 5; System.out.println("5个同学的平均分为: " + average); System.out.println("80分及以上的同学人数为: " + count); }

用Java编写:键盘输入5个同学的成绩并求出5个同学的平均分并统计80分以上有多少人。

原文地址: https://www.cveoy.top/t/topic/czWB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录