zoukankan      html  css  js  c++  java
  • 学生成绩统计管理

    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
  • 相关阅读:
    session 和 aplication 相关总结
    asp.net网站发布时碰到的一些问题
    考前防脑瘫防挂分预防针
    【游记】NOIP2021 白给记
    SELECT list is not in GROUP BY clause and contains nonaggregated
    StringUtils.isEmpty()
    gitLab生成SSH私钥后上传代码及获取代码
    tomcat配置https请求访问
    Mybatis:映射文件概述 & 增删改查
    Mybatis:核心文件概述
  • 原文地址:https://www.cnblogs.com/maskman/p/9102563.html
Copyright © 2011-2022 走看看