1、JAVA学生录取系统要求:Java编程/* 编写程序实现如下功能:已知学生类变量(姓名、考号、综合成绩、体育成绩)和方法 (获取综合成绩、获取体育成绩、显示基本信息) ,学校类有变量(录取分数线)和方法(设置录取分数、获取录取分数线) ,录取类有方法(获取学生是否符合录取条件,其中录取条件为综合成绩在录取分数线之上,或体育成绩在 96 分以上并且综合成绩大于 300 分)。现要求编写程序输出一组学生对象中被某学校录取的学生基本信息。*/1.Schools 类import java.util.*;public class Schools private double scoreLine;/ 录取
2、分数线private 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
3、schoolName;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( 录取分数线错误,请重新输入 )
4、;i=i-1;continue;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 Strin
5、g getFirstHope() 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=Intege
6、r.parseInt(sc.nextLine();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
7、( 请输入第二志愿 1. 北京大学 ;2.南京大学 );int choice=Integer.parseInt(sc.nextLine();if(choice=1&!student.getFirstHope().equals( 北京大学 ) rvs13 。student.setSecondHope( 北京大学 );break;else if(choice=2&!student.getFirstHope().equals( 南京大学 ) E6ux6。student.setSecondHope( 南京大学 );break;elseSystem.out.println( 无此学校,或者与第一志愿重复
8、,请重输 ); continue;while(true);public String getName() return 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;else
9、System.out.println( 综合成绩错误,请重新输入 );continue;while(true);public double getSportScore() return sportScore;public void setSportScore(double score) public void setSportScore() doSystem.out.println( 请输入体育成绩 );GAXJm。double sportscore1=Double.parseDouble(sc.nextLine();if(sportscore1=0)setSportScore(sportsc
10、ore1);break;elseSystem.out.println( 体育成绩错误,请重新输入 );continue;while(true);public void showInformation(Students student)System.out.println( 学 生 姓 名 为 : +student.getName()+ 学 生 考 号 为 : +student.getID()+ 综 合 成 绩 为 +student.getAllScore()+ 体 育 成 绩 为+student.getSportScore(); AuEPx。/ 构造器public Students(Strin
11、g name,int ID,double allScore,double sportScore) VpAbQ。this.name=name;this.ID=ID;this.allScore=allScore;this.sportScore=sportScore;public Students() / TODO Auto-generated constructor stub3.Enter 类(录取类)public class Enter Students student1=new Students();/ 判断录取public void enter(Students students,Schoo
12、ls schools) hANet。for(int i=0;i96)studentsi.setAllScore(0);for(int i=1;i=students.length-1;i+)for(int j=0;jstudentsj+1.getAllScore() 1mgCc。Students temp;temp=studentsj;studentsj=studentsj+1;studentsj+1=temp;int sum=0;int sum1=0;for(int i=0;istudents.length;i+)学VKwGGif(studentsi.getFirstHope().equals
13、( 北 京 大)&sumschools0.getScoreLine()sum=sum+1;System.out.println( 恭喜被北大录取 );student1.showInformation(studentsi);else if(studentsi.getFirstHope().equals( 南 京 大 学)&sum1schools1.getScoreLine() 5F9Lm。sum1=sum1+1;System.out.println( 恭喜被南京大学录取 );student1.showInformation(studentsi);else if(sumschools0.getNu
14、mber()&studentsi.getSecondHope().equals( 南京 大学 )&studentsi.getAllScore()schools1.getScoreLine() nSzPZ。sum1=sum1+1;System.out.println( 恭喜被南京大学录取 );student1.showInformation(studentsi);else if(sum1schools1.getNumber()&studentsi.getSecondHope().equals( 北 京大学 )&studentsi.getAllScore()schools0.getScoreLin
15、e() tOvms。sum=sum+1;System.out.println( 恭喜被北大录取 );student1.showInformation(studentsi);else if(sumschools0.getNumber()&sum1schools1.getNumber() UwyuE。System.out.println( 学校人数已满无法录取 );break;4.Demo 类(操作类)import java.util.*;public class Demo Scanner sc=new Scanner(System.in);Students students;Schools sc
16、hools=new Schools2 ;Schools school=new Schools();Enter en=new Enter();/ 确定两所大学分数线public void main()schools0=new Schools();schools0.setSchoolName( 北京大学 );System.out.println( 请输入北京大学录取人数 );int num1=Integer.parseInt(sc.nextLine(); schools0.setNumber(num1);schools1=new Schools();schools1.setSchoolName(
17、南京大学 );System.out.println( 请输入南京大学录取人数 );int num2=Integer.parseInt(sc.nextLine(); schools1.setNumber(num2); school.setScoreLine(schools);/ 输入学生信息 doSystem.out.println( 请输入学生位数 );int num=Integer.parseInt(sc.nextLine();if(num0)students=new Studentsnum;for(int i=0;istudents.length;i+)studentsi=new Stud
18、ents();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();
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1