(1)声明 Student 类,其成员变量包含学号、姓名、数学成绩和计算机成绩。要求:该类的构造方法中用到 this 关键字;对于每一个成员变量,都
要有对应的 set 方法和 get 方法来设置成员变量的值和获取成员变量的值。还要有一个 void print()方法,功能是输出成员变量的信息。
(2)在主类的 main 方法中,创建学生类的数组,从键盘上输入若干学生的信息,之后输出这些学生的信息;将学生信息分别按照两门课 程的成绩
升序排序。(画出内存分配图,手工画图拍照即可。)
class Student //定义学生类
{
private String stuno;
private String name;
private float math;
private float computer;
public Student() { }
public Student(String stuno, String name, float math, float computer) {
this.setStuno(stuno);
this.setName(name);
this.setMath(math);
this.setComputer(computer);
}
public void setStuno(String s) {
stuno = s;
}
public void setName(String n) {
name = n;
}
public void setMath(float m) {
math = m;
}
public void setComputer(float c) {
computer = c;
}
public String getStuno() {
return stuno;
}
public String getName() {
return name;
}
public float getMath() {
return math;
}
public float getcomputer() {
return computer;
}
public void print(){
System.out.println(stuno+","+name","+math+","+computer);
}
public class e1
{
public static void main(String[] args)
{
}
}