java课程设计题目及代码
题目:学生成绩管理系统
设计一个学生成绩管理系统,能够实现以下功能:
1. 添加学生信息:录入学生的姓名、学号、性别等基本信息。
2. 添加学生成绩:录入学生的各门成绩,包括语文、数学、英语等课程。
3. 查学生成绩:根据学号或姓名查学生的成绩信息。
4. 修改学生成绩:根据学号或姓名修改学生的成绩信息。
5. 删除学生成绩:根据学号或姓名删除学生的成绩信息。
6. 统计学生成绩:统计全班学生的各门课程的平均分、最高分和最低分。
代码实现如下:
```java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
class Student {
private String name;
private String studentId;
private String gender;
private Map<String, Integer> scores;
public Student(String name, String studentId, String gender) {
this.name = name;
this.studentId = studentId;
der = gender;
this.scores = new HashMap<>();
}
public String getName() {
return name;
}
public String getStudentId() {
return studentId;
}
public String getGender() {
return gender;
}
public Map<String, Integer> getScores() {
return scores;
}
public void addScore(String subject, int score) {
scores.put(subject, score);
}
public void updateScore(String subject, int score) {
scores.put(subject, score);
}
public void removeScore(String subject) {
ve(subject);
}
}
class GradeManagementSystem {
private ArrayList<Student> students;
public GradeManagementSystem() {
students = new ArrayList<>();
}
public void addStudent(String name, String studentId, String gender) {
students.add(new Student(name, studentId, gender));
}
public Student findStudentById(String studentId) {
基于java的课程设计题目 for (Student student : students) {
if (StudentId().equals(studentId)) {
return student;
}
}
return null;
}
public Student findStudentByName(String name) {
for (Student student : students) {
if (Name().equals(name)) {
return student;
}
}
return null;
}
public void addScore(String studentId, String subject, int score) {
Student student = findStudentById(studentId);
if (student != null) {
student.addScore(subject, score);
}
}
public void updateScore(String studentId, String subject, int score) {
Student student = findStudentById(studentId);
if (student != null) {
student.updateScore(subject, score);
}
}
public void removeScore(String studentId, String subject) {
Student student = findStudentById(studentId);
if (student != null) {
veScore(subject);
}
}
public void printStudentInfo(Student student) {
System.out.println("姓名:" + Name());
System.out.println("学号:" + StudentId());
System.out.println("性别:" + Gender());
System.out.println("成绩:");
for (Map.Entry<String, Integer> entry : Scores().entrySet()) {
System.out.Key() + ":" + Value());
}
}
public void printClassStatistics() {
int chineseTotal = 0;
int mathTotal = 0;
int englishTotal = 0;
int chineseMax = 0;
int mathMax = 0;
int englishMax = 0;
int chineseMin = Integer.MAX_VALUE;
int mathMin = Integer.MAX_VALUE;
int englishMin = Integer.MAX_VALUE;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论