Java's classic Student class

Source: Internet
Author: User

     classStudent {//Define student Number    PrivateString Stu; //Student Name    PrivateString name; //Student Letter Scores    Private floatMath; //students ' Chinese achievements    Private floatChinese; //Student English scores    Private float中文版; //Property Initialization     PublicStudent (String stu,string name,floatMathfloatChinese,float中文版) {        //Set Number         This. Setstu (Stu); //Set name         This. SetName (name); //Set Math scores         This. Setmath (math); //Set Language scores         This. Setchinese (Chinese); //set English scores         This. Setenglish (中文版); }    Private voidSetenglish (floate) {//TODO auto-generated Method StubEnglish=e; }    Private voidSetchinese (floatc) {//TODO auto-generated Method StubChinese=C; }    Private voidSetmath (floatm) {//TODO auto-generated Method StubMath=m; }    Private voidSetName (String N) {//TODO auto-generated Method StubName=N; }    Private voidSetstu (String s) {//TODO auto-generated Method Stubstu=s; }     PublicString GetName () {returnname; }     Public floatGetmath () {returnMath; }     Public floatGetchinese () {returnChinese; }     Public floatGetenglish () {return中文版; }         PublicString Getstu () {returnStu; }    //Score Score     Public floatsum () {returnMath+chinese+中文版; }    //Average score     Public floatavg () {return  This. SUM ()/3; }    //Highest score     Public floatMax () {floatmax=Math; Max= max > Chinese?Max:chinese; Max= max > 中文版?Max:english; returnMax; }    //Minimum Value     Public floatmin () {floatmin=Math; Min= Min < Chinese?Min:chinese; Min= Min < 中文版?Min:english; returnmin; }    //Test Class     Public Static classtest{ Public Static voidMain (String args[]) {student Stu=NULL; //instantiates a student object, and constructs a methodstu=NewStudent ("23", "Xiaoming", 90.0f,85.0f,97.0f); System.out.println ("Student Number:" +Stu.getstu ()); System.out.println ("Student Name:" +stu.getname ()); System.out.println ("Student Math Score:" +Stu.getmath ()); System.out.println ("Student language score:" +Stu.getchinese ()); System.out.println ("Student English score:" +stu.getenglish ()); System.out.println ("Total Score:" +stu.sum ()); System.out.println ("Average score:" +stu.avg ()); System.out.println ("Highest score:" +Stu.max ()); System.out.println ("Lowest Score:" +stu.min ()); }        }        }

Run

Student Number: Students ' name: Xiao Ming's students ' math score: 90.0 students ' Chinese score: 85.0 students ' English score: 97.0 score :272.0 average : 90.666664 Highest score:97.0 minimum score:85.0

Java's classic Student class

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.