注:这个程序要结合下面3个类才能运行:学生信息可以自己加/*1.编写一个学生成绩管理程序。
学生的属性包括学号、、年龄等。
每个学生要学习若干课程,每门课程有平时成绩、期中考试成绩、实习成绩、期末考试成绩以及总评成绩等多个成绩,其中平时成绩的数目不定(因为不同课程的教师布置的平时作业数不同),而总评成绩是其它成绩的平均值。
请先设计合理的对象容器类存放这些信息,然后设计程序完成以下功能:1)列出某个学生的所有成绩;2)列出某门课程每个学生的总评成绩,及所有学生总评成绩的总评分;3)分区段统计某门课程的学生总评成绩,例如60 分以下的学生人数、60 至70 分的学生人数等。
根据兴趣,你还可实现其它一些功能。
请仔细设计和组织你的类和使用的集合类对象。
*/package .geminno.day730.homework12;import java.util.ArrayList;import java.util.List;public class TestStudentManage {public static void main(String[] args) {List<Student> students = new ArrayList<Student>();//实例化对象List<Course> courses = new ArrayList<Course>();//实例化对象//第一个学生的信息:Course c = new Course("Web编程", 85, 69, 70, 75, 90);courses.add(c);c = new Course("编程思想", 95, 78, 86, 88, 80);courses.add(c);c = new Course("java编程", 90, 80, 75, 88, 92);courses.add(c);c = new Course("数据库",93,60,55,80,56);courses.add(c);Student s = new Student("2012", "三", 20, "男", "计算机", courses);students.add(s);//第二个学生courses = new ArrayList<Course>();c = new Course("Web编程", 80, 70, 50, 55, 60);courses.add(c);c = new Course("编程思想", 95, 77, 80, 66, 88);courses.add(c);c = new Course("java编程", 70, 80, 71, 82, 60);courses.add(c);c = new Course("数据库",60,60,55,75,70);courses.add(c);s = new Student("2013", "晓红", 18, "女", "计算机", courses);students.add(s);//第三个学生信息courses = new ArrayList<Course>();c = new Course("Web编程", 80, 79, 70, 75, 88);courses.add(c);c = new Course("编程思想", 95, 88, 56, 88, 89);courses.add(c);c = new Course("java编程", 90, 60, 75, 80, 92);courses.add(c);c = new Course("数据库",93,60,55,86,60);courses.add(c);s = new Student("2014", "海伦", 20, "女", "计算机", courses);students.add(s);StudentManage sm = new StudentManage(students);sm.showScoreBySno("2013");sm.showStaticsScore("数据库");sm.showTotalScore("java编程");}}学生管理类:package .geminno.day730.homework12;import java.util.List;public class StudentManage {//类private List<Student> students;public StudentManage(List<Student> students) {//构造函数super();this.students = students;}public void showScoreBySno(String sno){//方法if(sno == null) return;//如果sno为空,则返回for(Student s: students){//遍历student集合if(s.getSno().equals(sno)){//如果得到的学号和自己选的学号相等List<Course> courses = s.getCourses();//则得到相应的课程for(Course c : courses){//遍历course课程集合System.out.println(c);//输出}break;//跳出for循环}}}public void showTotalScore(String ame){//方法if(cname == null) return;//如果名字为空则返回int countStudent = 0;//定义整型初始值int totalScore = 0;//定义初始值System.out.println("选择"+cname+"有以下学生:");for(Student s : students){//遍历集合List<Course> courses = s.getCourses();for(Course c : courses){//遍历集合if(cname.equals(c.getCname())){//如果名字和得到的名字相同countStudent ++;//则相应的加1totalScore = totalScore +c.getTotalScore();System.out.println(s.getName()+"totalScore:"+c.getTotalSco re());//输出}}}System.out.println("所有学生总评成绩的总评分:"+(totalScore / countStudent));}public void showStaticsScore(String ame){//方法if(cname == null) return;//如果名字为空则返回int under60 = 0;//定义初始值int between6070 = 0;//定义初始值for(Student s : students){//遍历集合List<Course> courses = s.getCourses();for(Course c : courses){//遍历集合if(cname.equals(c.getCname())){if(c.getTotalScore()<60){//如果小于60under60 ++;//则加1}else if(c.getTotalScore()<=70){//如果在60和70之间between6070 ++;//则加1}}}}System.out.println("分数在60以下的:"+under60);//输出System.out.println("分数在60到70的:"+between6070);}}学生类:package .geminno.day730.homework12;import java.util.List;public class Student {private String sno;private String name;private int age;private String gender;private String major;private List<Course> courses;public String getSno() {return sno;}public void setSno(String sno) { this.sno = sno;}public String getName() {return name;}public void setName(String name) { = name;}public int getAge() {return age;}public void setAge(int age) { this.age = age;}public String getGender() {return gender;}public void setGender(String gender) {this.gender = gender;}public String getMajor() {return major;}public void setMajor(String major) {this.major = major;}public List<Course> getCourses() {return courses;}public void setCourses(List<Course> courses) {this.courses = courses;}public Student(String sno, String name, int age, String gender, String major, List<Course> courses) {super();this.sno = sno; = name;this.age = age;this.gender = gender;this.major = major;this.courses = courses;}}课程类:package .geminno.day730.homework12;public class Course {private String ame;private int usuallyScore;private int middleScore;private int praticeScore;private int finalScore;private int totalScore;public String getCname() {return ame;}public void setCname(String ame) {ame =ame;}public int getUsuallyScore() {return usuallyScore;}public void setUsuallyScore(int usuallyScore) { uallyScore = usuallyScore;}public int getMiddleScore() {return middleScore;}public void setMiddleScore(int middleScore) { this.middleScore = middleScore;}public int getPraticeScore() {return praticeScore;}public void setPraticeScore(int praticeScore) { this.praticeScore = praticeScore;}public int getFinalScore() {return finalScore;}public void setFinalScore(int finalScore) { this.finalScore = finalScore;}public int getTotalScore() {return totalScore;}public void setTotalScore(int totalScore) { this.totalScore = totalScore;}public Course(String ame, int usuallyScore, int middleScore, int praticeScore, int finalScore, int totalScore) {super();ame =ame;uallyScore = usuallyScore;this.middleScore = middleScore;this.praticeScore = praticeScore;this.finalScore = finalScore;this.totalScore = totalScore;}}。