Topic, write a Java application. Design a student class Students, including attributes are: serial number, student number, name, sex, profession, three courses scores (math, computer, English); methods include: seeking total score, average score, in addition to the serial number of each attribute assignment method, each attribute value of the acquisition method and so on. Description: Creates a Per Students object, the sequence number value by 1 ; the first sequence number value of a student object 1 .
Write a main class StudentsDemo, creating class Students five objects in the main process, the output information according to the following requirements:
(1) Each curriculum highest / lowest score students serial number, student number, course name and the score
(2) Total maximum / minimum number of students, number, name and score all courses
(3) Enter a number or school name, if there is such a student number or the names of all the student information is output, otherwise the output information does not exist.
Package StudentsDemo; Import java.util.Scanner; public class StudentsDemo { public static void main (String [] args) { // create a student information Student [] = A new new Student [. 5 ]; // stored as an array of five student class int I = 0 ; for (I = 0; I <. 5; I ++ ) { A [I] = new new student (); A [I] .math = ( int ) (Math.random () * 100 ); * // generates a random number between 0 and 100. 1 a [I] .English = ( int ) (Math.random () * 100); //Random number input result to A [I] Comp = ( int ) (Math.random () * 100 ); A [I] .gender = "M" ; A [I] .major = "Computer" ; // the System .out.println (a [i] .nunber) ; authentication ID } A [ 0] .stu_num = "125" ; A [ . 1] .stu_num = "244" ; A [ 2] .stu_num = "334" ; A [ . 3] .stu_num = "442" ; A [ . 4] .stu_num = "542" ; // Science No. A [ 0] .name = "John Doe" ; A [ . 1] .name = "inside" ; A [ 2] .name = "Dawn" ; a[3].name = "李华"; a[4].name = "丽华";//起名 int max1 = 0, min1 = 0; int max2 = 0, min2 = 0; int max3 = 0, min3 = 0; int MAX = 0; for (i = 0; i < 5; i++) { if (a[i].gettotal() > a[MAX].gettotal()) { MAX = i; } if (a[i].math > a[max1].math) { max1 = i; } if (a[i].math < a[min1].math) { min1 = i; } if (a[i].english > a[max2].english) { max2 = i; } if (a[i].english < a[max2].english) { min2 = i; } if (a[i].comp > a[max3].comp) { max3 = i;//寻找分高的人 } if (a[i].comp < a[min3].comp) { min3 = i; } } Put(a, "英语", max2); Put(a, "数学", max1); PUT (A, "computer" , max3); // Scanner (the System.in);Output learning information Put2 (a, "English" , MIN2); Put2 (A, "mathematics" , MIN1); Put2 (A, "computer" , min3); of Put (A, "" , MAX); System.out. the println ( "English sub" + A [MAX] .getEnglish ()); System.out.println ( "Mathematics into" + A [MAX] .getMath ()); System.out.println ( "computer score of" + A [MAX] .getComp ()); // output the highest total score // Find the student int CONT = -1 ; Scanner in = new new System.out.println ( "Please enter the number or school name" ); String search =in.nextLine (); for (I = 0; I <. 5; I ++ ) {// for string equality compare the equals IF (A [I] .name.equals (Search) || A [I] .stu_num.equals (Search)) { CONT = I; BREAK ; } } IF (CONT == -1 ) { System.out.println ( "information is not present" ); } the else { System.out.println ( "The name is" + A [CONT] .name); System.out.println ( "number is" + A [CONT] .nunber); System.out.println ( "student number is" +A [CONT] .stu_num); the System.out. println ( "gender" + A [CONT] .gender); System.out.println ( "specialty is" + A [CONT] .major); System.out.println ( "score in English "+ A [CONT] .getEnglish ()); System.out.println ( " math is "+ A [CONT] .math); System.out.println ( " computer achievement is "+ A [CONT] Comp ); System.out.println ( "out a" + A [CONT] .gettotal ()); System.out.println ( "average is" + A [CONT] .getaver ()); } } static void PUT (Student [] SS, String Course, int NUM) { the System.out.println(course + "is the highest achievement."+ Ss [num] .nunber + "number of students."); System.out.println ( "student number is" + SS [NUM] .stu_num); System.out.println ( "The name is" + SS [NUM] .name); IF (course.equals ( "Dictionary Dictionary English" )) {// semicolon not less System.out.println (Course + "score is" + SS [NUM] .English); } the else IF (course.equals ( "CoMP" )) { System.out.println ( Course + "score is" + SS [NUM] Comp); } the else IF (course.equals ( "Math" )) { System.out.println (Course + "score is" + SS [NUM] .math); } } static void Put2 (Student [] SS, Course, String, int NUM) { System.out.println (Course, + "lowest score is" + ss [num] .nunber + " student number" ); System.out.println ( " Learn number is "+ SS [NUM] .stu_num); System.out.println ( " The name is "+ SS [NUM] .name); IF (course.equals (" Dictionary Dictionary English " )) { System.out.println ( Course + "score is" + SS [NUM] .English); } the else IF (course.equals ( "CoMP" )) { System.out.println (Course + "score is" + SS [NUM] Comp); } else if (course.equals("math")) { System.out.println (Course + "score is" + SS [NUM] .math); } } }
package StudentsDemo; public class Student { static int NUM = 1; int nunber; String stu_num; String name; String gender; double math; double comp; double english; String major; Student() {//构造方法 nunber = NUM++; } public double gettotal() {//获取总分 return this.math + this.english + this.comp; } public double getaver() { return ((this.comp + this.english + this.math) * 1.0) / 3; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getComp() { return comp; } public void setComp(double comp) { this.comp = comp; } 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 String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public String getStu_num() { return stu_num; } public void setStu_num(String stu_num) { this.stu_num = stu_num; } public String getMajor() { return major; } public void setMajor(String major) { this.major = major; } }