public class Student {
private String id,name;
private int yw,sx,wy;
public Student(String id,String name){
this.id=id;
this.name=name;
}
public int getYw() {
return yw;
}
public void setYw(int yw) {
this.yw = yw;
}
public int getSx() {
return sx;
}
public void setSx(int sx) {
this.sx = sx;
}
public int getWy() {
return wy;
}
public void setWy(int wy) {
this.wy = wy;
}
private int getaverage(){ //学生平均成绩
return (yw+sx+wy)/3;
}
private void getlevel(){ //等级
int n=yw+sx+wy;
if(n>=270)
System.out.println(name+"的平均成绩为:"+this.getaverage()+"等级为优等生");
else if(n>=240)
System.out.println(name+"的平均成绩为:"+this.getaverage()+"等级为良好");
else if(n>=200)
System.out.println(name+"的平均成绩为:"+this.getaverage()+"等级为中等");
else if(n>=180)
System.out.println(name+"的平均成绩为:"+this.getaverage()+"等级为及格");
else
System.out.println(name+"的平均成绩为:"+this.getaverage()+"等级为不及格");
}
}
温馨提示:答案为网友推荐,仅供参考