package pr02; public class CourseTester { public static void main(String[] args) { System.out.println("CourseTester written by S. Robbins"); double[][] labs = { { 57, 89.4, 94 }, { 95, 88.3, 97 }, { 67, 72.8, 81 }, { 88, 72.3, 69 }, { 99, 87.0, 94 } }; double[][] quizzes = { { 40, 70, 65, 87 }, { 88, 93, 97, 89 }, { 45, 68, 82, 90 }, { 76, 92, 84, 76 }, { 95, 73, 94, 89 } }; double[][] exams = { { 98, 87.5 }, { 89, 93.3 }, { 65, 92.9 }, { 68, 73.3 }, { 87, 96.7 } }; String[] ids = { "firstp", "@0002", "abcd", "notp", "Num3" }; String[][] names = { { "George", "T", "Washington" }, { "John", "X", "Adams" }, { "John", "Q", "Adams" }, { "Samuel", "S", "Adams" }, { "Thomas", "J", "Jefferson" } }; Course cs1713 = new Course("Intro to Programming", "CS1713", new Name( "Weining", "", "Zhang"), "Fall 2007", 3, 4, 2); for (int i = 0; i < ids.length; i++) { cs1713.addStudent(names[i][0], names[i][1], names[i][2], ids[i]); setGrades(cs1713, ids[i], labs[i], quizzes[i], exams[i]); } System.out.println("Course with 5 students after inialization:"); cs1713.printByName(); cs1713.setLabGrade(ids[2], 2, 93.45); cs1713.setQuizGrade("notthere", 1, 23.1); System.out.println("John Q. Adams second lab is 93.45"); cs1713.printByName(); cs1713.addStudent("James", "M", "Madison", ids[2]); System.out.println("After trying to add a duplicate id"); cs1713.printByName(); Student gw = cs1713.getStudent(ids[0]); System.out.println("A copy of George Washington:"); System.out.println(gw); gw.setQuizGrade(1, 19.15); System.out.println("George Washington with first quiz 19.15:"); System.out.println(gw); System.out .println("Goerge Washing should not have changed in the course:"); cs1713.printByName(); System.out.println("Course sorted by id:"); cs1713.printById(); System.out.println("Course sorted by average:"); cs1713.printByCourseAverage(); cs1713.removeStudent("notp"); cs1713.removeStudent("notin"); System.out.println("Only Samuel Adams removed"); cs1713.printByName(); } private static void setGrades(Course course, String id, double[] labs, double[] quizzes, double[] exams) { for (int i = 0; i < labs.length; i++) course.setLabGrade(id, i + 1, labs[i]); for (int i = 0; i < quizzes.length; i++) course.setQuizGrade(id, i + 1, quizzes[i]); for (int i = 0; i < exams.length; i++) course.setExamGrade(id, i + 1, exams[i]); } }