《JAVA学生录取系统(共14页).docx》由会员分享,可在线阅读,更多相关《JAVA学生录取系统(共14页).docx(14页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上要求:Java编程/*编写程序实现如下功能:已知学生类变量(姓名、考号、综合成绩、体育成绩)和方法(获取综合成绩、获取体育成绩、显示基本信息),学校类有变量(录取分数线)和方法(设置录取分数、获取录取分数线),录取类有方法(获取学生是否符合录取条件,其中录取条件为综合成绩在录取分数线之上,或体育成绩在96分以上并且综合成绩大于300分)。现要求编写程序输出一组学生对象中被某学校录取的学生基本信息。*/1.Schools类import java.util.*;public class Schools private double scoreLine; /录取分数线pri
2、vate String schoolName; /学校名称private int number; /入取人数public int getNumber() return number;public void setNumber(int number) doif(number0)this.number = number;break;elseSystem.out.println(录取人数错误,请重输);continue;while(true);Scanner sc=new Scanner(System.in);public String getSchoolName() return schoolNa
3、me;public void setSchoolName(String schoolName) this.schoolName = schoolName;public double getScoreLine() return scoreLine;public void setSchoolLine(double SchoolLine) public void setScoreLine(Schools schools) for(int i=0;i300)setSchoolLine(scoreLine1);elseSystem.out.println(录取分数线错误,请重新输入);i=i-1;con
4、tinue;public Schools()2. Students类import java.util.*;public class Students Scanner sc=new Scanner(System.in);private String name; /姓名private int ID; /考号private double allScore; /综合成绩private double sportScore; /体育成绩private String firstHope; /第一志愿private String secondHope; /第二志愿public String getFirstH
5、ope() return firstHope;/确定第一志愿public void setFirstHope(String setFirstHope)this.firstHope=setFirstHope;public void setSecondHope(String setSecondHope)this.secondHope=setSecondHope;public void setFirstHope(Students student) doSystem.out.println(请输入第一志愿1.北京大学;2.南京大学);int choice=Integer.parseInt(sc.nex
6、tLine();if(choice=1)student.setFirstHope(北京大学);break;else if(choice=2)student.setFirstHope(南京大学);break;elseSystem.out.println(无此学校,请重输);continue;while(true);public String getSecondHope() return secondHope;/确定第二志愿public void setSecondHope(Students student) doSystem.out.println(请输入第二志愿1.北京大学;2.南京大学);i
7、nt choice=Integer.parseInt(sc.nextLine();if(choice=1&!student.getFirstHope().equals(北京大学)student.setSecondHope(北京大学);break;else if(choice=2&!student.getFirstHope().equals(南京大学)student.setSecondHope(南京大学);break;elseSystem.out.println(无此学校,或者与第一志愿重复,请重输);continue;while(true);public String getName() re
8、turn name;public void setName(String name) this.name = name;public int getID() return ID;public void setID(Students students) doSystem.out.println(请输入学生考号);int ID=Integer.parseInt(sc.nextLine();for(int i=0;i=0)setAllScore(allscore1);break;elseSystem.out.println(综合成绩错误,请重新输入);continue;while(true);pub
9、lic double getSportScore() return sportScore;public void setSportScore(double score) public void setSportScore() doSystem.out.println(请输入体育成绩);double sportscore1=Double.parseDouble(sc.nextLine();if(sportscore1=0)setSportScore(sportscore1);break;elseSystem.out.println(体育成绩错误,请重新输入);continue;while(tru
10、e); public void showInformation(Students student) System.out.println(学生姓名为:+student.getName()+ 学生考号为:+student.getID()+ 综合成绩为+student.getAllScore()+ 体育成绩为+student.getSportScore(); /构造器public Students(String name,int ID,double allScore,double sportScore)this.name=name;this.ID=ID;this.allScore=allScore
11、;this.sportScore=sportScore;public Students() / TODO Auto-generated constructor stub3. Enter类(录取类)public class Enter Students student1=new Students(); /判断录取public void enter(Students students,Schools schools)for(int i=0;i96)studentsi.setAllScore(0);for(int i=1;i=students.length-1;i+)for(int j=0;jstu
12、dentsj+1.getAllScore()Students temp;temp=studentsj;studentsj=studentsj+1;studentsj+1=temp;int sum=0;int sum1=0;for(int i=0;istudents.length;i+)if(studentsi.getFirstHope().equals(北京大学)&sumschools0.getScoreLine()sum=sum+1;System.out.println(恭喜被北大录取);student1.showInformation(studentsi);else if(students
13、i.getFirstHope().equals(南京大学)&sum1schools1.getScoreLine()sum1=sum1+1;System.out.println(恭喜被南京大学录取);student1.showInformation(studentsi);else if(sumschools0.getNumber()&studentsi.getSecondHope().equals(南京大学)&studentsi.getAllScore()schools1.getScoreLine()sum1=sum1+1;System.out.println(恭喜被南京大学录取);studen
14、t1.showInformation(studentsi);else if(sum1schools1.getNumber()&studentsi.getSecondHope().equals(北京大学)&studentsi.getAllScore()schools0.getScoreLine()sum=sum+1;System.out.println(恭喜被北大录取);student1.showInformation(studentsi);else if(sumschools0.getNumber()&sum1schools1.getNumber()System.out.println(学校人
15、数已满无法录取);break;4. Demo类(操作类)import java.util.*;public class Demo Scanner sc=new Scanner(System.in);Students students; Schools schools=new Schools2 ;Schools school=new Schools();Enter en=new Enter();/确定两所大学分数线public void main()schools0=new Schools();schools0.setSchoolName(北京大学);System.out.println(请输入
16、北京大学录取人数);int num1=Integer.parseInt(sc.nextLine();schools0.setNumber(num1);schools1=new Schools();schools1.setSchoolName(南京大学);System.out.println(请输入南京大学录取人数);int num2=Integer.parseInt(sc.nextLine();schools1.setNumber(num2);school.setScoreLine(schools);/输入学生信息doSystem.out.println(请输入学生位数);int num=In
17、teger.parseInt(sc.nextLine();if(num0)students=new Studentsnum;for(int i=0;istudents.length;i+)studentsi=new Students();System.out.println(请输入学生姓名);String name=sc.nextLine();studentsi.setName(name);studentsi.setID(students);studentsi.setAllScore();studentsi.setSportScore();studentsi.setFirstHope(studentsi);studentsi.setSecondHope(studentsi);/break;elseSystem.out.println(学生个数错误,请重输);continue;while(true);en.enter(students,schools);public static void main(String args) / TODO Auto-generated method stubDemo de = new Demo();de.main();专心-专注-专业
限制150内