题目六:学生成绩管理系统设计学生成绩信息包括:学期,学号,班别,姓名,四门课程成绩(体育、高等数学、大学英语和计算机基础)等。主要功能:
(1) 能按学期、按班级完成对学生成绩的录入、修改
(2) 能按班级统计学生的成绩,求学生的总分及平均分
(3) 能查询学生成绩,不及格科目及学生名单(4) 能按班级输出学生的成绩单
要求:存储数据方式不限,系统以菜单方式工作
java程序设计学生管理系统系统设计
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- 语言-逆行者 2023-04-12 11:39关注
基于ChatGPT加以修改过后的回答:
【1】学生类
public class Student { private String term; // 学期 private String id; // 学号 private String className; // 班别 private String name; // 姓名 private double sportsScore; // 体育成绩 private double mathScore; // 高等数学成绩 private double englishScore; // 大学英语成绩 private double computerScore; // 计算机基础成绩 // 构造函数 public Student(String term, String id, String className, String name, double sportsScore, double mathScore, double englishScore, double computerScore) { this.term = term; this.id = id; this.className = className; this.name = name; this.sportsScore = sportsScore; this.mathScore = mathScore; this.englishScore = englishScore; this.computerScore = computerScore; } // getter和setter方法 public String getTerm() { return term; } public void setTerm(String term) { this.term = term; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getClassName() { return className; } public void setClassName(String className) { this.className = className; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getSportsScore() { return sportsScore; } public void setSportsScore(double sportsScore) { this.sportsScore = sportsScore; } public double getMathScore() { return mathScore; } public void setMathScore(double mathScore) { this.mathScore = mathScore; } public double getEnglishScore() { return englishScore; } public void setEnglishScore(double englishScore) { this.englishScore = englishScore; } public double getComputerScore() { return computerScore; } public void setComputerScore(double computerScore) { this.computerScore = computerScore; } // 计算总分 public double getTotalScore() { return sportsScore + mathScore + englishScore + computerScore; } // 计算平均分 public double getAverageScore() { return getTotalScore() / 4; } // 判断是否不及格 public boolean isFailed() { return sportsScore < 60 || mathScore < 60 || englishScore < 60 || computerScore < 60; } // 输出成绩单 public void printScore() { System.out.println("学期:" + term); System.out.println("学号:" + id); System.out.println("班别:" + className); System.out.println("姓名:" + name); System.out.println("体育成绩:" + sportsScore); System.out.println("高等数学成绩:" + mathScore); System.out.println("大学英语成绩:" + englishScore); System.out.println("计算机基础成绩:" + computerScore); System.out.println("总分:" + getTotalScore()); System.out.println("平均分:" + getAverageScore()); if (isFailed()) { System.out.println("不及格科目:"); if (sportsScore < 60) { System.out.println("体育"); } if (mathScore < 60) { System.out.println("高等数学"); } if (englishScore < 60) { System.out.println("大学英语"); } if (computerScore < 60) { System.out.println("计算机基础"); } } } }
【2】成绩管理系统类:
import java.util.ArrayList; import java.util.Scanner; public class ScoreManagementSystem { private ArrayList<Student> students; // 学生列表 // 构造函数 public ScoreManagementSystem() { students = new ArrayList<Student>(); } // 添加学生 public void addStudent(Student student) { students.add(student); } // 按学期查询学生 public void queryByTerm(String term) { System.out.println("查询结果:"); for (Student student : students) { if (student.getTerm().equals(term)) { student.printScore(); } } } // 按班级查询学生 public void queryByClass(String className) { System.out.println("查询结果:"); for (Student student : students) { if (student.getClassName().equals(className)) { student.printScore(); } } } // 修改学生成绩 public void updateScore(String id, String course, double score) { for (Student student : students) { if (student.getId().equals(id)) { switch (course) { case "体育": student.setSportsScore(score); break; case "高等数学": student.setMathScore(score); break; case "大学英语": student.setEnglishScore(score); break; case "计算机基础": student.setComputerScore(score); break; default: System.out.println("错误:无效的课程名称"); break; } return; } } System.out.println("错误:找不到该学生"); } // 统计班级成绩 public void statistics(String className) { int count = 0; double totalScore = 0; for (Student student : students) { if (student.getClassName().equals(className)) { count++; totalScore += student.getTotalScore(); } } double averageScore = totalScore / count; System.out.println("班级:" + className); System.out.println("人数:" + count); System.out.println("总分:" + totalScore); System.out.println("平均分:" + averageScore); } // 查询不及格学生名单 public void queryFailedStudents() { System.out.println("不及格学生名单:"); for (Student student : students) { if (student.isFailed()) { System.out.println(student.getName()); } } } // 输出班级成绩单 public void printScoreList(String className) { System.out.println("班级成绩单:"); for (Student student : students) { if (student.getClassName().equals(className)) { student.printScore(); } } } // 菜单 public void menu() { Scanner scanner = new Scanner(System.in); while (true) { System.out.println("1. 录入学生成绩"); System.out.println("2. 按学期查询学生成绩"); System.out.println("3. 按班级查询学生成绩"); System.out.println("4. 修改学生成绩"); System.out.println("5. 统计班级成绩"); System.out.println("6. 查询不及格学生名单"); System.out.println("7. 输出班级成绩单"); System.out.println("0. 退出"); System.out.print("请输入操作编号:"); int choice = scanner.nextInt(); switch (choice) { case 1: System.out.print("请输入学期:"); String term = scanner.next(); System.out.print("请输入学号:"); String id = scanner.next(); System.out.print("请输入班别:"); String className = scanner.next(); System.out.print("请输入姓名:"); String name = scanner.next(); System.out.print("请输入体育成绩:"); double sportsScore = scanner.nextDouble(); System.out.print("请输入高等数学成绩:"); double mathScore = scanner.nextDouble(); System.out.print("请输入大学英语成绩:"); double englishScore = scanner.nextDouble(); System.out.print("请输入计算机基础成绩:"); double computerScore = scanner.nextDouble(); Student student = new Student(term, id, className, name, sportsScore, mathScore, englishScore, computerScore); addStudent(student); System.out.println("学生成绩录入成功"); break; case 2: System.out.print("请输入学期:"); term = scanner.next(); queryByTerm(term); break; case 3: System.out.print("请输入班级:"); className = scanner.next(); queryByClass(className); break; case 4: System.out.print("请输入学号:"); id = scanner.next(); System.out.print("请输入课程名称:"); String course = scanner.next(); System.out.print("请输入成绩:"); double score = scanner.nextDouble(); updateScore(id, course, score); break; case 5: System.out.print("请输入班级:"); className = scanner.next(); statistics(className); break; case 6: queryFailedStudents(); break; case 7: System.out.print("请输入班级:"); className = scanner.next(); printScoreList(className); break; case 0: System.out.println("程序已退出"); return; default: System.out.println("错误:无效的操作编号"); break; } } } // 测试 public static void main(String[] args) { ScoreManagementSystem system = new ScoreManagementSystem(); system.menu(); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 帮我调试idea基于spring boot项目
- ¥15 es 7.17.20版本生成时间戳
- ¥15 wpf dategrid表头排序图标自定义
- ¥15 分析下图所示同步时序逻辑电路的逻辑功能。
- ¥15 halcon联合c#遇到了问题不能解决
- ¥15 xshell无法连接提示ssh服务器拒绝密码
- ¥15 AT89C52单片机C语言关于串口通信的位操作
- ¥20 需要步骤截图(标签-服务器|关键词-map)
- ¥50 gki vendor hook
- ¥15 灰狼算法和蚁群算法如何结合