Recently Java opened an object-oriented curriculum, the teacher assigned the homework, ah, that is, what homework I don't how to describe, code as follows, do their own, code is very immature, please understand! That's about it:
classstudent{PrivateString Stuno; PrivateString name; Private floatMath; Private float中文版; Private floatcomputer; /*Student () {}*/ Public voidstuper (String stuno,string name) { This. Stuno =Stuno; This. Name =name; } Public voidStugrade (floatMathfloat中文版,floatcomputer) { This. Math =Math; This. 中文版 =中文版; This. Computer =computer; } Public voidcount () {floatAverage = (math + 中文版 + computer)/3; System.out.println ("Average score:" +average); floatsum = (Math + 中文版 +computer); System.out.println ("Total:" +sum); floatMax = 0; if(Math >中文版) {Max=Math; } Else{Max=中文版; } if(Max >computer) {System.out.println ("Highest score:" +max); } Else{System.out.println ("Highest score:" +computer); } floatMin = 0; if(Math >中文版) {min=中文版; } Else{min=Math; } if(Min >computer) {System.out.println ("Minimum score:" +computer); } Else{System.out.println ("Minimum score:" +min); } } Public voidTell () {System.out.println ("Name:" + name + "study Number:" +Stuno); System.out.println ("Math Score:" + math + "English score:" + 中文版 + "Computer score:" +computer); }}classstuinfo{ Public Static voidMain (string[] args) {Student person=NewStudent (); Person. Stuper ("2015025500", "Zhang San"); Person.stugrade (50,60,70); Person.tell (); Person.count (); } }
The result of the program operation is:
Name: Zhang Sanxu No.: 2015025500
Math score: 50.0 English score: 60.0 Computer score: 70.0
Average score: 60.0
Total: 180.0
The highest score is: 70.0
Minimum score: 50.0
Java programming Basics Object-oriented practice