public class Student {
/**
* @param args
*/
boolean master; //定义成员变量
int num;
String name,sex;
double math,chinese,english,score=0.0,average=0.0;
Student(int num,String name, String sex, boolean ma, double math, double chinese, double english ){ //构造方法
this.num = num;
this.name = name;
this.sex = sex;
this.master = ma;
this.math = math;
this.chinese = chinese;
this.english = english;
}
void score(){ //计算总分方法
score= math+chinese+english;
System.out.println(score);
}
void ave(){ //计算平均分方法
average = score/3;
System.out.println(average);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s = new Student(101,"kit","male",true,90.0,90.0,90.0); //创建对象
s.score(); //调用方法
s.ave();
}
}