A simple class design topic

Source: Internet
Author: User
Tags float max

The code is as follows:

Class student{private String name;private int age;private float english;private float math;private float computer;public S Tudent () {};p ublic Student (String name,int age,float english,float math,float computer) {this.setname (name); This.setage (age); This.setenglish (中文版); This.setmath (math); this.setcomputer (computer);} public float sum () {return math+computer+english;} public float max () {float Max=math>computer?math:computer;max=max>english?max:english;return max;} public Float Ave () {return MATH+COMPUTER+ENGLISH/3;} Public String GetName () {return name;} public void SetName (String name) {this.name = name;} public int getage () {return age;} public void Setage (int.) {this.age = age;} public float Getenglish () {return 中文版;} public void Setenglish (float 中文版) {this.english = 中文版;} public float Getmath () {return math;} public void Setmath (float math) {this.math = math;} public float Getcomputer () {return computer;} public void Setcomputer (float computer) {this.computer = computer;}} PubliC class StudentDemo1 {public static void main (string[] args) {Student s=new Student ("Obama", 56,35,88,19); System.out.println (S.getname ()); System.out.println (S.getage ()); System.out.println (S.getcomputer ()); System.out.println (S.getenglish ()); System.out.println (S.getmath ()); System.out.println (S.sum ()); System.out.println (S.ave ()); System.out.println (S.max ());}}


A simple class design topic

Related Article

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.