设计一个学生类`。里面有姓名、性别、地址、学号成绩的属性。用一个方法输出上述信
设计一个学生类`。里面有姓名、性别、地址、学号成绩的属性。用一个方法输出上述信息。class student {
//定义成员变量
String name;
String sex;
String street;
int studentnumber;
float score;
//构造方法
public student(String name,String sex,String street,int studentnumber,float score)//传参数
{
this.name=name;
this.sex=sex;
this.street=street;
this.studentnumber=studentnumber;
this.score=score;
}
void print()
{
System.out.println("the name is "+name);
System.out.println("the sex is "+sex);
System.out.println("the street is "+street);
System.out.println("the studentnumber is "+studentnumber);
System.out.println("the score is "+score);
}
}
public class Class
{
public static void main(String[] agrs)
{
student pt=new student("guofeng","M","jinlong park",44,100.0f);//调用构造方法并传递参数
//调用输出方法
pt.print();
}
}
高手指点下。我不懂老师的作业