码迷,mamicode.com
首页 > 其他好文 > 详细

学生成绩统计管理

时间:2018-05-29 00:15:19      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:str   inf   ret   pack   oid   ota   system   pre   out   

package student_control class Grade {
    private double english;
    private double math;
    private double chinese;
     
    public Grade(double english, double math, double chinese) {
        this.english = english;
        this.math = math;
        this.chinese = chinese;
    }
 
    public double total() {
        return english + math + chinese;
    }
     
    public void printTotal() {
        System.out.println(total());
    }
     
    public double average() {
        return total() / 3;
    }
     
    public void printAverage() {
        System.out.println(average());
    }
    public double getEnglish() {
        return english;
    }
 
    public void setEnglish(double english) {
        this.english = english;
    }
 
    public double getMath() {
        return math;
    }
 
    public void setMath(double math) {
        this.math = math;
    }
 
    public double getChinese() {
        return chinese;
    }
 
    public void setChinese(double chinese) {
        this.chinese = chinese;
    }
}



public class Student {
    String name;
    Grade grade;
    public Student(String name, Grade grade) {
        this.name = name;
        this.grade = grade;
    }
     
    public static void main(String[] args) {
        Student s = new Student("李明", new Grade(90, 80, 70));
        s.grade.printAverage();
        s.grade.printTotal();
    }
}
李明
90,80,70
80.0
240.0

学生成绩统计管理

标签:str   inf   ret   pack   oid   ota   system   pre   out   

原文地址:https://www.cnblogs.com/maskman/p/9102563.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!