JAVA学生录取系统方案.docx
《JAVA学生录取系统方案.docx》由会员分享,可在线阅读,更多相关《JAVA学生录取系统方案.docx(10页珍藏版)》请在冰豆网上搜索。
JAVA学生录取系统方案
要求:
Java编程
/*编写程序实现如下功能:
已知学生类变量(姓名、考号、综合成绩、体育成绩)和方法
(获取综合成绩、获取体育成绩、显示基本信息),学校类有变量(录取分数线)和方法
(设置录取分数、获取录取分数线),录取类有方法(获取学生是否符合录取条件,
其中录取条件为综合成绩在录取分数线之上,
或体育成绩在96分以上并且综合成绩大于300分)。
现要求编写程序输出一组学生对象中被某学校录取的学生基本信息。
*/
〔.Schools类
importjava.util.*;
publicclassSchools{
privatedoublescoreLine;
//录取分数线
privateStringschoolName;
//学校名称
privateintnumber;
//入取人数
publicintgetNumber(){
returnnumber;
}
publicvoidsetNumber(intnumber){
do{
if(number>0){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;iSystem.out.println(”请输入"+schools[i].getSchoolName()+"doublescoreLine仁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=lnteger.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;
}
publicvoidsetlD(Students[]students){
do{
System.out.println(”请输入学生考号");intID=Integer.parseInt(sc.nextLine());
for(inti=0;iif(ID==students[i].getlD()){
System.out.println(”考号存在请重输");
break;
}else{
this」D=ID;return;
}
}
}while(true);
}
publicdoublegetAllScore(){
returnallScore;
}
publicvoidsetAIIScore(doubleallScore){
this.allScore=allScore;
}
publicvoidsetAllScore(){
do{
System.out.println("请输入综合成绩");
doubleallscore仁Double.parseDouble(sc.nextLine());if(allscore1>=0){setAllScore(allscorel);
break;
}else{
System.out.println(”综合成绩错误,请重新输入”);
continue;
}
}while(true);
}
publicdoublegetSportScore(){
returnsportScore;
}
publicvoidsetSportScore(doublescore){}
publicvoidsetSportScore(){
do{
System.out.println("请输入体育成绩");
doublesportscore仁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.getlD()+"综合成绩为"+student.getAIIScore()+"
"+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{
Studentsstudent仁newStudents();
//判断录取
publicvoidenter(Students[]students,Schools[]schools){
for(inti=0;iif(students[i].getSportScore()>96){
students[i].setAIIScore(0);
}
}
for(inti=1;i<=students.length-1;i++){
for(intj=O;jif(students[j].getAIIScore()>students[j+1].getAllScore()){
Studentstemp;
temp=students[j];
students[j]=students[j+1];
students[j+1]=temp;
}
}
intsum=O;
intsum1=0;
for(inti=O;iif(students[i].getFirstHope().equals(”北京大学
”)&&;sumschools[0].getScoreLine(
)){
sum=