2、某小组有5位同学,每位同学包含的属性有no(学号)、name(姓名)和score(C语言成绩),且三个属性均为私有;编写一学生类Studs,能输出该小组每位同学信息并输出他们的C平均成绩。
程序运行后输出:
no name score
35003 Li 80
35002 Ma 90
35005 He 75
35008 Wu 65
35006 Ba 85
C平均成绩为:79.0
class Studs {
//将类补充完整
}
public class Sy2_6 {
public static void main(String[ ] args) {
Studs s1 = new Studs(35003,"Li",80);
Studs s2 = new Studs(35002,"Ma",90);
Studs s3 = new Studs(35005,"He",75);
Studs s4 = new Studs(35008,"Wu",65);
Studs s5 = new Studs(35006,"Ba",85);
System.out.println("no "+" name "+"score");
s1.show(); s2.show(); s3.show();
s4.show(); s5.show();
System.out.println("C平均成绩为:"+Studs.aver());
}
}