这里有一个程序,帮忙看看

wangke820819 2004-06-23 11:53:13
定义并测试一个Student类,包括属性,学号,姓名,以及三门成绩,数学,英语,计算机,算总分,平均分,最高分,最低分。
谢谢。在线等
...全文
123 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
tiger_wkh52741 2004-06-23
  • 打赏
  • 举报
回复
朋友如果这么简单的程序都要别人帮忙的话,学习java就没有什么意义了!

eclipse0016 2004-06-23
  • 打赏
  • 举报
回复
HawaiiLeo(罗马数字)

好迅速啊,呵呵
jellen 2004-06-23
  • 打赏
  • 举报
回复
楼主想让人给你写个程序吧。
HawaiiLeo 2004-06-23
  • 打赏
  • 举报
回复
运行结果:

Student Mechile sum:261
Student Mechile arg:87
Student Mechile max:90
Student Mechile min:82

Process completed.
刚现写的,希望你不是用来交作业。
HawaiiLeo 2004-06-23
  • 打赏
  • 举报
回复
/*定义并测试一个Student类
*包括属性,学号,姓名,以及三门成绩,数学,英语,计算机
*算总分,平均分,最高分,最低分
*/

public class Student
{
private String no;
private String name;
private int math = 0;
private int eng = 0;
private int comp = 0;

//构造函数
Student(String no, String name)
{
this.no = no;
this.name = name;
}


Student(String no, String name, int math, int eng, int comp)
{
this(no, name);

this.math = math;
this.eng = eng;
this.comp = comp;
}

//取值
public String getNo()
{
return no;
}
public String getName()
{
return name;
}
public int getMath()
{
return math;
}
public int getEng()
{
return eng;
}
public int getComp()
{
return comp;
}

//附值
public void setName(String name)
{
this.name = name;
}
public void setMath(int math)
{
this.math = math;
}
public void setEng(int eng)
{
this.eng = eng;
}
public void setComp(int comp)
{
this.comp = comp;
}

//算总分
public int sum()
{
return(math + eng + comp);
}
//平均分
public int arg()
{
return(sum() /3);
}
//最高分
public int max()
{
int tmp = Math.max(math, eng);

if(tmp < comp)
{
tmp = comp;
}

return tmp;
}
//最低分
public int min()
{
int tmp = Math.min(math, eng);

if(tmp > comp)
{
tmp = comp;
}

return tmp;
}

public static void main(String argv[])
{
Student s = new Student("9772039", "Mechile");
s.setMath(90);
s.setEng(82);
s.setComp(89);

System.out.println("Student "+ s.getName() +" sum:" + s.sum());
System.out.println("Student "+ s.getName() +" arg:" + s.arg());
System.out.println("Student "+ s.getName() +" max:" + s.max());
System.out.println("Student "+ s.getName() +" min:" + s.min());
}
}
ericzh 2004-06-23
  • 打赏
  • 举报
回复
^_^没有程序怎么看啊?
mtou 2004-06-23
  • 打赏
  • 举报
回复
程序,出错信息
eclipse0016 2004-06-23
  • 打赏
  • 举报
回复
程序呢?
lixiang823517 2004-06-23
  • 打赏
  • 举报
回复
晕,你要干吗???
说明白~
blasterboy 2004-06-23
  • 打赏
  • 举报
回复
顺便说一句,我觉得,学生,和取它的分数,应该分开,至少应该两个类
blasterboy 2004-06-23
  • 打赏
  • 举报
回复
自己多动动手,这样才是好的学习习惯。
xueqs 2004-06-23
  • 打赏
  • 举报
回复
同意楼上朋友的意见

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧