标题:设计一个学生类`。里面有姓名、性别、地址、学号成绩的属性。用一个方法输出 ...
只看楼主
xiaota261536
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-10-14
 问题点数:0 回复次数:0 
设计一个学生类`。里面有姓名、性别、地址、学号成绩的属性。用一个方法输出上述信
设计一个学生类`。里面有姓名、性别、地址、学号成绩的属性。用一个方法输出上述信息。

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();
}
}


高手指点下。我不懂老师的作业


搜索更多相关主题的帖子: 学生类 学号成绩 上述信 String 性别 
2007-10-14 11:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-177483-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017275 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved