Design 10 students score information, the students have 3 courses, the calculation of the students total peace and evenly. Sort output

Source: Internet
Author: User

public class Grade {      private double english;      private double math;      private double sql;           public Grade( double english,  double math,  double sql) {          this .english = english;          this .math = math;          this .sql = sql;      }      public double total() {          return english + math + sql;      }           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 getSql() {          return sql;      }      public void setSql( double sql) {          this .sql = sql;      } }

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 (100, 94, 90));
S.grade.printaverage ();
S.grade.printtotal ();
}
}
Results:

94.66666
284.0

Design 10 students score information, the students have 3 courses, the calculation of the students total peace and evenly. Sort output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.