用JAVA编写一个学校课程管理系统
时间: 2023-08-22 12:03:36 浏览: 109
基于java的学校管理系统
好的,一个学校课程管理系统通常包括以下模块:
1. 学生信息管理模块:包括学生个人信息录入、修改、查询、删除等功能;
2. 教师信息管理模块:包括教师个人信息录入、修改、查询、删除等功能;
3. 课程信息管理模块:包括课程信息的录入、修改、查询、删除等功能;
4. 选课管理模块:包括学生选课、教师查看选课情况、课程开设情况等功能;
5. 成绩管理模块:包括成绩录入、查询、统计等功能。
下面是一个简单的学校课程管理系统的JAVA代码示例,供您参考:
```java
import java.util.ArrayList;
import java.util.Scanner;
public class CourseManagementSystem {
public static void main(String[] args) {
ArrayList<Student> students = new ArrayList<Student>();
ArrayList<Teacher> teachers = new ArrayList<Teacher>();
ArrayList<Course> courses = new ArrayList<Course>();
ArrayList<Enrollment> enrollments = new ArrayList<Enrollment>();
Scanner scanner = new Scanner(System.in);
// 添加学生、教师和课程信息
System.out.println("请输入学生信息:");
students.add(new Student(scanner.nextLine()));
System.out.println("请输入教师信息:");
teachers.add(new Teacher(scanner.nextLine()));
System.out.println("请输入课程信息:");
courses.add(new Course(scanner.nextLine()));
// 学生选课
System.out.println("请选择课程:");
for (int i = 0; i < courses.size(); i++) {
System.out.println((i + 1) + "." + courses.get(i).getName());
}
int choice = scanner.nextInt();
enrollments.add(new Enrollment(students.get(0), courses.get(choice - 1)));
// 教师录入成绩
System.out.println("请输入成绩:");
int score = scanner.nextInt();
enrollments.get(0).setScore(score);
// 查询成绩统计信息
int totalScore = 0;
int count = 0;
for (Enrollment enrollment : enrollments) {
totalScore += enrollment.getScore();
count++;
}
int averageScore = totalScore / count;
System.out.println("平均成绩为:" + averageScore);
}
}
class Student {
private String name;
public Student(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
class Teacher {
private String name;
public Teacher(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
class Course {
private String name;
public Course(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
class Enrollment {
private Student student;
private Course course;
private int score;
public Enrollment(Student student, Course course) {
this.student = student;
this.course = course;
}
public Student getStudent() {
return student;
}
public Course getCourse() {
return course;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
}
```
这是一个非常简单的示例,您可以根据自己的需要进行修改和完善。
阅读全文