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

    学生成绩管理

    public 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("Cici", new Grade(75, 88, 92));
            s.grade.printAverage();
            s.grade.printTotal();
        }
    }

    实验结果:

         85.0

         255.0

  • 相关阅读:
    准备Activiti环境(2)
    准备Activiti环境
    Activiti工作流的简单介绍
    html(5) css
    html(4)表单
    html(3)框架标签,内联框架
    字符输出流写文本文件【Writer、FileWriter 、BufferedReader 】
    二进制文件的读写
    字符输入流读取文本文件【Reader、FileReader、BufferedReader 】
    字节输入流写文本文件【OutputStream、FileOutputStream】
  • 原文地址:https://www.cnblogs.com/kongdexiu-13/p/9102497.html
Copyright © 2011-2022 走看看