```java import java.util.Scanner; class Score { int usualScore; int finalScore; int calculateTotalScore() { return (int) (usualScore * 0.4 + finalScore * 0.6); } } class Student { String studentId; String name; Score chineseScore; Score mathScore; Score physicsScore; int calculateTotalScore() { return chineseScore.calculateTotalScore() + mathScore.calculateTotalScore() + physicsScore.calculateTotalScore(); } double calculateAverageScore() { return (double) calculateTotalScore() / 3; } } public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Student[] students = new Student[3]; for (int i = 0; i < 3; i++) { Student student = new Student(); System.out.print("请输入第" + (i + 1) + "个学生的学号:"); student.studentId = scanner.nextLine(); System.out.print("请输入第" + (i + 1) + "个学生的姓名:"); student.name = scanner.nextLine(); System.out.println("请输入第" + (i + 1) + "个学生的语文平时成绩和期末成绩:"); Score chineseScore = new Score(); chineseScore.usualScore = scanner.nextInt(); chineseScore.finalScore = scanner.nextInt(); student.chineseScore = chineseScore; System.out.println("请输入第" + (i + 1) + "个学生的数学平时成绩和期末成绩:"); Score mathScore = new Score(); mathScore.usualScore = scanner.nextInt(); mathScore.finalScore = scanner.nextInt(); student.mathScore = mathScore; System.out.println("请输入第" + (i + 1) + "个学生的物理平时成绩和期末成绩:"); Score physicsScore = new Score(); physicsScore.usualScore = scanner.nextInt(); physicsScore.finalScore = scanner.nextInt(); student.physicsScore = physicsScore; students[i] = student; scanner.nextLine(); // 处理输入流中的换行符 } for (Student student : students) { System.out.println("总分:" + student.calculateTotalScore()); System.out.printf("平均分:%.2f\n", student.calculateAverageScore()); } } } ``` [2024-11-19 15:54:02 | AI写代码神器 | 581点数解答]