您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 绩效管理 > JAVA学生录取系统
要求:Java编程/*编写程序实现如下功能:已知学生类变量(姓名、考号、综合成绩、体育成绩)和方法(获取综合成绩、获取体育成绩、显示基本信息),学校类有变量(录取分数线)和方法(设置录取分数、获取录取分数线),录取类有方法(获取学生是否符合录取条件,其中录取条件为综合成绩在录取分数线之上,或体育成绩在96分以上并且综合成绩大于300分)。现要求编写程序输出一组学生对象中被某学校录取的学生基本信息。*/1.Schools类importjava.util.*;publicclassSchools{privatedoublescoreLine;//录取分数线privateStringschoolName;//学校名称privateintnumber;//入取人数publicintgetNumber(){returnnumber;}publicvoidsetNumber(intnumber){do{if(number0){this.number=number;break;}else{System.out.println(录取人数错误,请重输);continue;}}while(true);}Scannersc=newScanner(System.in);publicStringgetSchoolName(){returnschoolName;}publicvoidsetSchoolName(StringschoolName){this.schoolName=schoolName;}publicdoublegetScoreLine(){returnscoreLine;}publicvoidsetSchoolLine(doubleSchoolLine){}publicvoidsetScoreLine(Schools[]schools){for(inti=0;ischools.length;i++){System.out.println(请输入+schools[i].getSchoolName()+录取分数线);doublescoreLine1=Double.parseDouble(sc.nextLine());if(scoreLine1300){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;istudents.length;i++){if(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;istudents.length;i++){if(students[i].getSportScore()96){students[i].setAllScore(0);}}for(inti=1;i=students.length-1;i++){for(intj=0;jstudents.length-i;j++){if(students[j].getAllScore()students[j+1].getAllScore()){Studentstemp;temp=students[j];students[j]=students[j+1];students[j+1]=temp;}}}intsum=0;intsum1=0;for(inti=0;istudents.length;i++){if(students[i].getFirstHope().equals(北京大学)&&sumschools[0].getNumber()&&students[i].getAllScore()schools[0].getScoreLine()){sum=sum+1;System.out.println(恭喜被北大录取);student1.showInformation(students[i]);}elseif(students[i].getFirstHope().equals(南京大学)&&sum1schools[1].getNumber()&&students[i].getAllScore()schools[1].getScoreLine()){sum1=sum1+1;System.out.println(恭喜被南京大学录取);student1.showInformation(students[i]);}elseif(sumschools[0].getNumber()&&students[i].getSecondHope().equals(南京大学)&&students[i].getAllScore()schools[1].getScoreLine()){sum1=sum1+1;System.out.println(恭喜被南京大学录取);student1.showInformation(students[i]);}elseif(sum1schools[1].getNumber()&&students[i].getSecondHope().equals(北京大学)&&students[i].getAllScore()schools[0].getScoreLine()){sum=sum+1;System.out.println(恭喜被北大录取);student1.showInformation(students[i]);}elseif(sumschools[0].getNumber()&&sum1schools[1].getNumber()){System.out.println(学校人数已满无法录取);break;}}}}4.Demo类(操作类)importjava.util.*;publicclassDemo{Scanne
本文标题:JAVA学生录取系统
链接地址:https://www.777doc.com/doc-7191548 .html