Java 实现:三系学生成绩管理与综合成绩计算系统
```java interface ComprehensiveScore { double calculateComprehensiveScore(); } class Student { private String studentId; private String name; private String gender; private int age; public Student(String studentId, String name, String gender, int age) { this.studentId = studentId; this.name = name; this.gender = gender; this.age = age; } public String getStudentId() { return studentId; } public String getName() { return name; } public String getGender() { return gender; } public int getAge() { return age; } @Override public String toString() { return "学号:" + studentId + " 姓名:" + name + " 性别:" + gender + " 年龄:" + age; } } class EnglishStudent extends Student implements ComprehensiveScore { private double speechScore; private double finalExamScore; private double midtermExamScore; public EnglishStudent(String studentId, String name, String gender, int age, double speechScore, double finalExamScore, double midtermExamScore) { super(studentId, name, gender, age); this.speechScore = speechScore; this.finalExamScore = finalExamScore; this.midtermExamScore = midtermExamScore; } @Override public double calculateComprehensiveScore() { return speechScore * 0.5 + finalExamScore * 0.25 + midtermExamScore * 0.25; } } class ComputerStudent extends Student implements ComprehensiveScore { private double operationAbilityScore; private double englishWritingScore; private double finalExamScore; private double midtermExamScore; public ComputerStudent(String studentId, String name, String gender, int age, double operationAbilityScore, double englishWritingScore, double finalExamScore, double midtermExamScore) { super(studentId, name, gender, age); this.operationAbilityScore = operationAbilityScore; this.englishWritingScore = englishWritingScore; this.finalExamScore = finalExamScore; this.midtermExamScore = midtermExamScore; } @Override public double calculateComprehensiveScore() { return operationAbilityScore * 0.4 + englishWritingScore * 0.2 + finalExamScore * 0.2 + midtermExamScore * 0.2; } } class LiteratureStudent extends Student implements ComprehensiveScore { private double speechScore; private double workScore; private double finalExamScore; private double midtermExamScore; public LiteratureStudent(String studentId, String name, String gender, int age, double speechScore, double workScore, double finalExamScore, double midtermExamScore) { super(studentId, name, gender, age); this.speechScore = speechScore; this.workScore = workScore; this.finalExamScore = finalExamScore; this.midtermExamScore = midtermExamScore; } @Override public double calculateComprehensiveScore() { return speechScore * 0.35 + workScore * 0.35 + finalExamScore * 0.15 + midtermExamScore * 0.15; } } public class Main { public static void main(String[] args) { // 创建可容纳 6 个学生的数组 Student[] students = new Student[6]; // 英语系学生 students[0] = new EnglishStudent("001", "张三", "男", 20, 80, 70, 60); students[1] = new EnglishStudent("002", "李四", "女", 21, 90, 80, 70); // 计算机系学生 students[2] = new ComputerStudent("003", "王五", "男", 22, 85, 75, 65, 75); students[3] = new ComputerStudent("004", "赵六", "女", 23, 95, 85, 75, 85); // 文学系学生 students[4] = new LiteratureStudent("005", "孙七", "男", 24, 80, 80, 70, 60); students[5] = new LiteratureStudent("006", "周八", "女", 25, 90, 90, 80, 70); for (Student student : students) { System.out.println(student.toString() + " 综合成绩:" + ((ComprehensiveScore) student).calculateComprehensiveScore()); } } } ``` 额外注意逻辑点: 1. 确保输入的成绩数据在合理范围内,避免出现异常结果。 2. 考虑添加异常处理机制,以应对可能出现的非法输入或计算错误。 3. 如果需要对学生信息进行修改或扩展功能,注意修改相关的类和方法。 ######[AI写代码神器 | 1215点数解答 | 2025-05-13 18:55:25]
- Python 实战:统计学生成绩与大学类型数量,附代码及注意点(字节豆包 | 388点数解答 | 2025-05-09 10:52:51)259
- C 语言:快速实现 5 个学生信息录入、按成绩升序排序并输出!(字节豆包 | 373点数解答 | 2024-10-30 00:37:20)412
- C语言实现:输入5名学生信息并按成绩升序排序输出(字节豆包 | 354点数解答 | 2024-10-30 18:45:58)356
- C语言:输入5个学生信息,按成绩升序排序并输出(字节豆包 | 373点数解答 | 2024-10-31 19:49:58)350
- C语言:输入5名学生信息并按成绩升序排序输出(字节豆包 | 326点数解答 | 2025-01-01 20:11:47)344
- Java 实现复制粘贴功能:打造简易文本复制粘贴程序(GPT | 1497点数解答 | 2024-08-25 09:40:33)409
- 成绩等级统计:20个60 - 100分成绩的等级数量揭秘(字节豆包 | 219点数解答 | 2025-04-09 10:20:32)219
- 培训机构学员成绩与年龄更新:C++ 代码实现(DeepSeek | 186点数解答 | 2025-12-16 18:04:31)62
- Python 处理培训机构学员培训后年龄与 NOIP 成绩提升情况(DeepSeek | 73点数解答 | 2025-12-16 18:05:20)68
- 培训机构学员成绩提升:C++代码实现年龄与NOIP成绩更新(DeepSeek | 178点数解答 | 2025-12-31 12:20:24)62
- 解决数据库“dm.jdbc.driver.dmexception: 数据溢出”问题的全步骤指南(阿里通义 | 598点数解答 | 2024-10-15 15:48:38)310
- 达梦数据库数据溢出问题排查及多维度解决方法(阿里通义 | 403点数解答 | 2024-10-15 15:48:41)1149