Define an array of Student, which save the students' basic information, including name, Student number, gender, also save three courses grades and three courses respectively corresponding credits, try programming calculation of the three courses for credit product, and follow the power reduction credits product sort, sorted output as a result,
CodePudding user response:
Define a class students, students basic information and credit attribute.
Define a student an array of types, new a few students in.
Traverse each student to obtain the array, and then remove the attribute evaluation and sorting. The output
CodePudding user response:
reference 1/f, Java, elementary student's reply: define a class students, students basic information and credit attribute. Define a student an array of types, new a few students in. Traverse each student to obtain the array, and then remove the attribute evaluation and sorting. Output Can make up the code, please, thank you CodePudding user response:
refer to the second floor qq_45069331 response: Quote: reference Java - 1/f, elementary student's reply: define a class students, include students basic information and credit attribute. Define a student an array of types, new a few students in. Traverse each student to obtain the array, and then remove the attribute evaluation and sorting. Output Can make up the code, please, thank you public class Day05152019 { Public static void main (String [] args) { Student1 [s]=new Student1 [3]. S [0]=new Student1 (" wang ", "001", "male", 20.0, 2.5, 80.0, 5.0, 68.0, 4.5); S [1]=new Student1 (" zhang ", "002", "male", 50.0, 2.5, 60.0, 5.0, 78.0, 4.5); S [2]=new Student1 (" xiao li ", "003", "male", 30.0, 2.5, 50.0, 5.0, 88.0, 4.5); Map for (int i=0; i Double v=s [I] getACredit () * s [I] getAScore () + s [I] getBCredit () * s [I] getBScore () + s [I] getCCredit () * s [I] getCScore (); The map. The put (v, s [I]); } Iterator It=map. KeySet (). The iterator (); While (it. HasNext ()) { Double next=it. Next (); System. The out. Println (next + "aaaaa" + map. Get (next). The toString ()); } } } The class Student1 { //including name, student number, gender, also save three courses grades and three courses respectively corresponding credits private String name; private String id; private String sex; Private Double AScore; Private Double ACredit; Private Double BScore; Private Double BCredit; Private Double CScore; Private Double CCredit; Public Student1 (String name, String id, String sex, Double AScore, Double ACredit, Double BScore, Double BCredit, Double CScore, Double CCredit) { this.name=name; This. Id=id; this.sex=sex; Enclosing AScore=AScore; Enclosing ACredit=ACredit; Enclosing BScore=BScore; Enclosing BCredit=BCredit; Enclosing CScore=CScore; Enclosing CCredit=CCredit; } Public String getName () { return name; } Public void elegantly-named setName (String name) { this.name=name; } Public String getId () { return id; } Public void setId (String id) { This. Id=id; } Public String getSex () { return sex; } Public void setSex (String sex) { this.sex=sex; } Public Double getAScore () { Return AScore; } Public void setAScore (Double AScore) { Enclosing AScore=AScore; } Public Double getACredit () { Return ACredit; } Public void setACredit (Double ACredit) { Enclosing ACredit=ACredit; } Public Double getBScore () { Return BScore; } Public void setBScore (Double BScore) { Enclosing BScore=BScore; } Public Double getBCredit () { Return BCredit; } Public void setBCredit (Double BCredit) { Enclosing BCredit=BCredit; } Public Double getCScore () { Return CScore; } Public void setCScore (Double CScore) { Enclosing CScore=CScore; } Public Double getCCredit () { Return CCredit; } Public void setCCredit (Double CCredit) { Enclosing CCredit=CCredit; } @ Override Public String toString () { Return Student1 {" + " "Name='" + name +' \ '+' "Id='" + id +' \ ' '+ ='" + ", sex sex +' \ ' '+ ", AScore="+ AScore + ", ACredit="+ ACredit + ", BScore="+ BScore + ", BCredit="+ BCredit + ", CScore="+ CScore + ", CCredit="+ CCredit + '} '; } } CodePudding user response:
Public class Student { /* * member variables: name, student number, gender, mathematics, English, Chinese, math credits, credits, English language credits, three courses for credit product Additional: sorting, according to credit product drop power output */ Public float Math;//mathematical Public float English;//English Public float Chinese;//the language Public int MathCredit;//math credits Public int EnglishCredit;//English credits Public int ChineseCredit;//the language credits Public float product;//credit product public String name; Public String Id; Public String sex; Public static void main (String [] args) {//initializes the array Student stu1=new Student (); { Stu1. Name="* *"; Stu1. Id="* * *"; Stu1. Sex="male"; Stu1. Math=70; Stu1. MathCredit=5; Stu1. English=73; Stu1. EnglishCredit=4; Stu1. Chinese=83; Stu1. ChineseCredit=3; Stu1. Product=stu1. Math * stu1 MathCredit + stu1. English * stu1 EnglishCredit + stu1. Chinese * stu1 ChineseCredit; System. The out. Println (" name "+ stu1. Name); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull