中易网

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

答案:3  悬赏:20  
解决时间 2021-01-11 05:00
  • 提问者网友:寂寞撕碎了回忆
  • 2021-01-10 21:58
跪求编写一个java程序,求chinese.math.以及english三个整型属性的平均值
最佳答案
  • 二级知识专家网友:未来江山和你
  • 2021-01-10 22:15
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楼网友:低血压的长颈鹿
  • 2021-01-11 00:00
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楼网友:猎心人
  • 2021-01-10 22:26
class Student {
String name;
int age;
int Chinese;
int Math;
int English;
int total() {
return Chinese + Math + English;
}
int average() {
return total() / 3;
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息