classstudent{Stringname;Stringid;floatywscore;floatsxscore;floatsumscore;floatavgscore;student(Stringname,Stringid,floatywscore,floatsxscore){this.name=name;this.id=id;th...
class student {
String name;
String id;
float ywscore;
float sxscore;
float sumscore;
float avgscore;
student(String name,String id,float ywscore,float sxscore){
this.name=name;
this.id=id;
this.ywscore=ywscore;
this.sxscore=sxscore;
}
float sum(){
sumscore=sxscore+ywscore;
return sumscore;
}
float avg(){
avgscore=(sxscore+ywscore)/2;
return avgscore;
}
void showinfo(){
System.out.println("name: "+name);
System.out.println("id: "+id);
System.out.println("mathscore: "+sxscore);
System.out.println("langue: "+ywscore);
System.out.println("avg: "+avg());
System.out.println("sum: "+sum());
}
};
public class text {
public static void main(String [] args){
student s=new student("McGrady","01",90,99);
s.showinfo();
}
}创建多个STUDENT对象 统计student的个数!
展开