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

    public class Grade 
    {
        private:
                   double english;
         double math;
        double Chinese;
         
        public:
                  Grade(double english, double math, double Chinese)
         {
            this.english = english;
            this.math = math;
            this.Chinese = Chinese;
        }
     
         double sum() 
        {
            return this.english+this.math+this.Chinese;
        }
         
         void displayTotal() 
        {
            System.out.println(sum());
        }
         
         double average() 
        {
            return sum()/3;
        }
         
         void displayAverage() 
        {
            System.out.println(average());
        }
         double getEnglish() 
        {
            return english;
        }
     
         void setEnglish(double english)
         {
            this.english = english;
        }
     
        double getMath()
         {
            return math;
        }
     
        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(70, 6090));
            s.grade.printAverage();
            s.grade.printTotal();
        }
    }
  • 相关阅读:
    飞思卡尔单片机CAN模块的物理特性的示波器观察
    飞思卡尔CAN模块关于ID和mask的使用
    基本数据库语句
    深入分析Spring 与 Spring MVC容器
    Linux常用命令大全
    datagrid行内编辑时为datetimebox
    SVN上拖下来的项目,缺少build path怎么办?
    sql中的in与not in,exists与not exists的区别
    Spring中@Component的作用
    浅谈@RequestMapping @ResponseBody 和 @RequestBody 注解的用法与区别
  • 原文地址:https://www.cnblogs.com/hjza/p/9134776.html
Copyright © 2011-2022 走看看