欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

教务管理系统之单门成绩录入模块

程序员文章站 2022-07-10 20:23:02
...

教务管理系统之单门成绩录入模块

需求

完成一个教务管理系统中的学生单门课程(课程名:《Java程序设计》)成绩录入模块,学生分数由平时成绩和期末成绩和最终成绩构成,其中平时成绩占比40%,期末成绩占比60%,满分100分,要求输入学生的平时成绩和期末成绩后自动计算得出总评成绩(注:所有成绩保留小数点后一位)

要求实现功能如下:
学生成绩录入
显示所有学生成绩

学号 姓名 平时成绩 期末成绩 总评成绩

1001 盖伦 100 80 88
1002 玛尔扎哈 90 70 78
1003 安妮 100 90 94
1004 孙悟空 90 100 96
1005 猪八戒 60 50 54

需求分析

1.创建一个学生类,包含学号、姓名、课程名、平时成绩、期末成绩、总评成绩。生成无参和带所有参数的构造器及每个属性set()、get()方法。因为这里总评成绩是由平时成绩和期末成绩计算而来,所以应该将构造器中总评成绩的赋值方式加以修改并删除set总评成绩的方法。
2.创建学生管理类,可以用ArrayList实现学生的录入和成绩查询

功能实现

Student类

public class Student {
	
	private String sno;
	private String sname;
	private String course;
	private double usualScore;//平时成绩
	private double endScore;//期末成绩
	private double finalScore;//总评成绩
	
	public Student() {
		super();
	}
	public Student(String sno, String sname, String course, double usualScore, double endScore) {
		super();
		this.sno = sno;
		this.sname = sname;
		this.course = course;
		this.usualScore = usualScore;
		this.endScore = endScore;
		this.finalScore = usualScore * 0.4 + endScore * 0.6;
	}
	public String getSno() {
		return sno;
	}
	public void setSno(String sno) {
		this.sno = sno;
	}
	public String getSname() {
		return sname;
	}
	public void setSname(String sname) {
		this.sname = sname;
	}
	public String getCourse() {
		return course;
	}
	public void setCourse(String course) {
		this.course = course;
	}
	public double getUsualScore() {
		return usualScore;
	}
	public void setUsualScore(double usualScore) {
		this.usualScore = usualScore;
	}
	public double getEndScore() {
		return endScore;
	}
	public void setEndScore(double endScore) {
		this.endScore = endScore;
	}
	public double getFinalScore() {
		return finalScore;
	}
	
	@Override
	public String toString() {
		return sno + "\t" + sname + "\t\t" + usualScore + "\t" + endScore + "\t" + finalScore;
	}
}

StudentManagement类

import java.util.ArrayList;

public class StudentManagement {
	
	ArrayList<Student> list = new ArrayList<>();
	
	public void input(Student s){
		list.add(s);
	}
	
	public void showAll(){
		System.out.println("学号\t姓名\t\t平时成绩\t期末成绩\t总评成绩");
		System.out.println("-----------------------------------------------");
		for (Student student : list) {
			System.out.println(student);
		}
	}
}

测试类

public class Test {
	
	public static void main(String[] args) {
		StudentManagement sm = new StudentManagement();
		Student s1 = new Student("1001","盖伦","《Java程序设计》",100,80);
		Student s2 = new Student("1002","玛尔扎哈","《Java程序设计》",90,70);
		Student s3 = new Student("1003","安妮","《Java程序设计》",100,90);
		Student s4 = new Student("1004","孙悟空","《Java程序设计》",90,100);
		Student s5 = new Student("1005","猪八戒","《Java程序设计》",60,50);
		
		sm.input(s1);
		sm.input(s2);
		sm.input(s3);
		sm.input(s4);
		sm.input(s5);

		sm.showAll();
	}

}
相关标签: 功能实现 java