标题:学生类信息,该怎么修改
取消只看楼主
bizika526
Rank: 1
等 级:新手上路
帖 子:45
专家分:0
注 册:2007-10-20
 问题点数:0 回复次数:0 
学生类信息,该怎么修改

class Student{
private String id;
private String name;
private String sex;
private String phone;
private String chengji;

public Student(String i,String n,String s,String p,String c){
this.id=i;
this.name=n;
this.sex=s;
this.phone=p;
this.chengji=c;

}


public String getId(){
return this.id;
}

public String getName(){
return this.name;
}

public String getSex(){
return this.sex;
}

public String getPhone(){
return this.phone;
}

public String getChengji(){
return this.chengji;
}
;
}

class Test{
public static void main(String[] args){
Student s1=new Student("学号: 017","姓名:张大华","性别:男","电话:5887185","java成绩: 60");
Student s2=new Student("学号: 018","姓名:张小华","性别:男","电话:5887185","java成绩: 80");
System.out.println(s1.getId());
System.out.println(s1.getName());
System.out.println(s1.getSex());
System.out.println(s1.getPhone());
System.out.println(s1.getChengji());
System.out.println();
System.out.println(s2.getId());
System.out.println(s2.getName());
System.out.println(s2.getSex());
System.out.println(s2.getPhone());
System.out.println(s2.getChengji());
System.out.println();
float ave;
ave=(85+80)/2;
System.out.println("两人的平均成绩为:"+ave);
}
}
为什么运行结果中ave=82.0,改了分数后,结果仍为82.0,错在哪儿?另外此类中求平均成绩可以要哪种方法?求平均成绩应该怎么求?,望各位帮忙解答,谢谢

搜索更多相关主题的帖子: 学生 
2007-11-01 14:00



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




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

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