JAVA.....急

来源:百度知道 编辑:UC知道 时间:2024/06/05 04:34:33
编程题:定义一个表示学生的类(Student),类中包括表示学号、姓名、年龄、语数外三门课程成绩的数据成员,及用于设置与获取学号、姓名、年龄、语数外三门课程成绩的方法成员,将其打包;创建TestStudent类,导入前面创建的包,在TestStudent中生成5个学生对象,计算3门课程的平均成绩,以及某门课程的最高分与最低分。

//Student.java文件
package school;
public class Student {
private String stuNo; //学号
private String name; //姓名
private int age; //年龄
private double math; //数学分数
private double english; //英语分数
private double chinese; //语文分数

public Student(){}
public Student(String stuNo,String name,int age,double math,double english,double chinese){
this.stuNo = stuNo;
this.name = name;
this.age = age;
this.math = math;
this.english = english;
this.chinese = chinese;
}

public String getStuNo() {
return stuNo;
}

public void setStuNo(String stuNo) {
this.stuNo = stuNo;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}