用Java设计一个学生成绩管理系统,通过该系统可以实现如下功能; (1)录入功能:可以录入学生信息,学生信息包括学号、姓名、3门课程(数据结构、网 页开发基础、英语)成绩 (10分) (2)按平均成绩排序功能:计算出每个学生的平均成绩,按照学生平均成绩由高到低排序。 (15分) (1)按学号排序功能:按照学生的学号进行排序。 (10分) (1)统计功能:统计出平均分最高的学生、不及格学生信息及人数、平均分在80分以上 的学生信息及人数。 (15分) (2)查找功能:指定学号,从学生信息表中找到该学生
时间: 2024-02-19 07:57:27 浏览: 64
好的,以下是一个基于Java的学生成绩管理系统的设计和实现,可以实现录入、排序、统计和查找功能:
```
import java.util.*;
public class StudentManagementSystem {
private List<Student> students;
public StudentManagementSystem() {
students = new ArrayList<Student>();
}
public void addStudent(Student student) {
students.add(student);
}
public void sortByAverageScore() {
Collections.sort(students, new Comparator<Student>() {
public int compare(Student s1, Student s2) {
return Double.compare(s2.getAverageScore(), s1.getAverageScore());
}
});
}
public void sortByStudentId() {
Collections.sort(students, new Comparator<Student>() {
public int compare(Student s1, Student s2) {
return s1.getStudentId().compareTo(s2.getStudentId());
}
});
}
public void printHighestAverageScore() {
double highestScore = 0;
List<Student> highestScorers = new ArrayList<Student>();
for (Student student : students) {
if (student.getAverageScore() > highestScore) {
highestScore = student.getAverageScore();
highestScorers.clear();
highestScorers.add(student);
} else if (student.getAverageScore() == highestScore) {
highestScorers.add(student);
}
}
System.out.println("Highest average score: " + highestScore);
System.out.println("Highest scorers: " + highestScorers);
}
public void printFailingStudents() {
List<Student> failingStudents = new ArrayList<Student>();
for (Student student : students) {
if (student.getAverageScore() < 60) {
failingStudents.add(student);
}
}
System.out.println("Failing student count: " + failingStudents.size());
System.out.println("Failing students: " + failingStudents);
}
public void printHighScoringStudents() {
List<Student> highScoringStudents = new ArrayList<Student>();
for (Student student : students) {
if (student.getAverageScore() >= 80) {
highScoringStudents.add(student);
}
}
System.out.println("High-scoring student count: " + highScoringStudents.size());
System.out.println("High-scoring students: " + highScoringStudents);
}
public Student findStudentById(String id) {
for (Student student : students) {
if (student.getStudentId().equals(id)) {
return student;
}
}
return null;
}
}
public class Student {
private String studentId;
private String name;
private int dataStructureScore;
private int webDevelopmentScore;
private int englishScore;
public Student(String id, String name, int dataStructureScore, int webDevelopmentScore, int englishScore) {
this.studentId = id;
this.name = name;
this.dataStructureScore = dataStructureScore;
this.webDevelopmentScore = webDevelopmentScore;
this.englishScore = englishScore;
}
public String getStudentId() {
return studentId;
}
public String getName() {
return name;
}
public int getDataStructureScore() {
return dataStructureScore;
}
public int getWebDevelopmentScore() {
return webDevelopmentScore;
}
public int getEnglishScore() {
return englishScore;
}
public double getAverageScore() {
return (dataStructureScore + webDevelopmentScore + englishScore) / 3.0;
}
public String toString() {
return name + " (" + studentId + "): " + getAverageScore();
}
}
```
以上代码中,定义了一个学生管理系统的类StudentManagementSystem和一个学生类Student。学生管理系统包括添加学生、按平均成绩排序、按学号排序、打印平均分最高的学生、打印不及格学生和打印平均分在80分以上的学生等功能,而学生类则包括学号、姓名和三门课程成绩等字段。可以通过调用这些方法来实现对学生信息的管理和查询。
以上代码仅作为示例,实际开发中还需要根据具体情况进行修改和完善。
阅读全文