跪求编写一个java程序,求chinese.math.以及english三个整型属性的平均值

编写一个Java程序,在程序中定义一个Student类,并且完善Student类的结构。
按模板要求,将【代码1】~【代码5】替换为相应的Java程序代码。 //Student.java
class Student{
String name;
Int age;
【代码1】 //定义一个整型属性Chinese
【代码2】 //定义一个整型属性Math
【代码3】 //定义一个整型属性English
Int total()
{
【代码4】 //返回Chinese、Math及English3个整型属性的总和
}
Int average()
{
【代码5】 //返回Chinese、Math及English3个整型属性的平均值
}
}

public class Student{
String name;
int age;
int Chinese;//定义一个整型属性Chinese
int Math=4;//定义一个整型属性Math
int English;//定义一个整型属性English
int total()
{
return this.Chinese+this.English+this.Math;//返回Chinese、Math及English3个整型属性的总和
}
int average(){
return this.total()/3;//返回Chinese、Math及English3个整型属性的平均值
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-11-01
class Student{
    String name;
    Int age;
    Int Chinese;
    Int Math;
    Int English;
    Int total(){
        return this.Chinese+this.Math+this.English;
    }
    Int average(){
        return this.total()/3;
    }
}

  

第2个回答  2013-11-01
class Student {
String name;
int age;
int Chinese;
int Math;
int English;

int total() {
return Chinese + Math + English;
}

int average() {
return total() / 3;
}
}

相似回答