System.out.println("请输入"+schools[i].getSchoolName()+"录取分数线");
doublescoreLine1=Double.parseDouble(sc.nextLine());
if(scoreLine1>300){
setSchoolLine(scoreLine1);
}else{
System.out.println("录取分数线错误,请重新输入");
i=i-1;
continue;
}
}
}
publicSchools(){
}
}
2.Students类
importjava.util.*;
publicclassStudents{
Scannersc=newScanner(System.in);
privateStringname;//姓名
privateintID;//考号
privatedoubleallScore;//综合成绩
privatedoublesportScore;//体育成绩
privateStringfirstHope;//第一志愿
privateStringsecondHope;//第二志愿
publicStringgetFirstHope(){
returnfirstHope;
}
//确定第一志愿
publicvoidsetFirstHope(StringsetFirstHope){
this.firstHope=setFirstHope;
}
publicvoidsetSecondHope(StringsetSecondHope){
this.secondHope=setSecondHope;
}
publicvoidsetFirstHope(Studentsstudent){
do{
System.out.println("请输入第一志愿1.北京大学;2.南京大学");
intchoice=Integer.parseInt(sc.nextLine());
if(choice==1){
student.setFirstHope("北京大学");
break;
}elseif(choice==2){
student.setFirstHope("南京大学");
break;
}
else{
System.out.println("无此学校,请重输");
continue;
}
}while(true);
}
publicStringgetSecondHope(){
returnsecondHope;
}
//确定第二志愿
publicvoidsetSecondHope(Studentsstudent){
do{
System.out.println("请输入第二志愿1.北京大学;2.南京大学");
intchoice=Integer.parseInt(sc.nextLine());
if(choice==1&&!
student.getFirstHope().equals("北京大学")){
student.setSecondHope("北京大学");
break;
}elseif(choice==2&&!
student.getFirstHope().equals("南京大学")){
student.setSecondHope("南京大学");
break;
}
else{
System.out.println("无此学校,或者与第一志愿重复,请重输");
continue;
}
}while(true);
}
publicStringgetName(){
returnname;
}
publicvoidsetName(Stringname){
this.name=name;
}
publicintgetID(){
returnID;
}
publicvoidsetID(Students[]students){
do{
System.out.println("请输入学生考号");
intID=Integer.parseInt(sc.nextLine());
for(inti=0;iif(ID==students[i].getID()){
System.out.println("考号存在请重输");
break;
}else{
this.ID=ID;
return;
}
}
}while(true);
}
publicdoublegetAllScore(){
returnallScore;
}
publicvoidsetAllScore(doubleallScore){
this.allScore=allScore;
}
publicvoidsetAllScore(){
do{
System.out.println("请输入综合成绩");
doubleallscore1=Double.parseDouble(sc.nextLine());
if(allscore1>=0){
setAllScore(allscore1);
break;
}else{
System.out.println("综合成绩错误,请重新输入");
continue;
}
}while(true);
}
publicdoublegetSportScore(){
returnsportScore;
}
publicvoidsetSportScore(doublescore){}
publicvoidsetSportScore(){
do{
System.out.println("请输入体育成绩");
doublesportscore1=Double.parseDouble(sc.nextLine());
if(sportscore1>=0){
setSportScore(sportscore1);
break;
}else{
System.out.println("体育成绩错误,请重新输入");
continue;
}
}while(true);
}
publicvoidshowInformation(Studentsstudent){
System.out.println("学生姓名为:
"+student.getName()+"学生考号为:
"+student.getID()+"综合成绩为"+student.getAllScore()+"体育成绩为"+student.getSportScore());
}
//构造器
publicStudents(Stringname,intID,doubleallScore,doublesportScore){
this.name=name;
this.ID=ID;
this.allScore=allScore;
this.sportScore=sportScore;
}
publicStudents(){
//TODOAuto-generatedconstructorstub
}
}
3.Enter类(录取类)
publicclassEnter{
Studentsstudent1=newStudents();
//判断录取
publicvoidenter(Students[]students,Schools[]schools){
for(inti=0;iif(students[i].getSportScore()>96){
students[i].setAllScore(0);
}
}
for(inti=1;i<=students.length-1;i++){
for(intj=0;jif(students[j].getAllScore()>students[j+1].getAllScore()){
Studentstemp;
temp=students[j]