You are on page 1of 7

CS 201, Fall 2013

Homework Assignment 1 Due: 23:59, November 22, 2013


In this homework, you will implement a student-review-system for an instructor. The instructor oers multiple courses in a semester and each course can be taken by dierent number of students. The grading scheme of each course is dierent. Therefore, for each course, dierent number of grading components (exams) can exist. The student-review-system will have the following functionalities; the details of these functionalities are given below: 1. Add a course 2. Delete a course 3. Add a student 4. Drop a student 5. Add a grade form 6. Delete a grade form 7. Show the list of courses 8. Show detailed information about a particular course 9. Show detailed information about a particular student Add a course: The student-review-system will allow the instructor to add a new course indicating its course id and course name. Since the course ids are unique, the system should check whether or not the specied course id already exists (i.e., whether or not it is the id of another course), and if the course exists, it should not allow the operation and display a warning message. Delete a course: The student-review-system will allow the instructor to delete an existing course indicating its course id. If the course does not exist (i.e., if there is no course with the specied id), the system should display a warning message. Note that this operation will also drop all students from the course of interest. Similarly, all grade forms of the course of interest should be deleted. Add a student: The student-review-system will allow the instructor to add a student to a particular course. For that, the instructor will specify the course id and the information about the student. This information includes the student id and the name of the student. The system should rst check whether or not this course exists; if it does not, it should prevent to add a student and display a warning message. The student ids are unique so that two students with the same id do not exist. Thus, you should check whether or not this student has already been added to the specied course. If this is the case, the system should prevent to add a student and display a warning message. Note that if any exams were already given to the class before the time of adding the student, the grades of the student for all these exams will be 0 in the corresponding grade forms. Drop a student: The student-review-system will allow the instructor to drop a particular student from a course. For that, the instructor will specify the course id and the student id. If there is no course with the specied course id, the system should display a warning message. Similarly, if there is no student with the specied student id, the system should display a warning message. Otherwise, it will display the student information including his/her student id, and drop the student from the course. Note that in this operation, the system will also delete all grades taken by this student. Also note that, this operation drops the student from a single course; in other words, if this student is taking more than one course, this operation does not have any eects for the other courses. 1

Add a grade form: The student-review-system will allow the instructor to add a grade form for the course whose course id is specied. The grade form should include the following information: Form id, The contribution percentage (weight) to the total course grade of a student, and Grades of the students that are taking the course whose course id is specied. In this operation, for each student, the name and student id are displayed and the instructor is prompted to enter the grade of this student using the keyboard. Here you may assume that all grades entered by the instructor are valid grades (between 0 and 100). The contribution percentage (weight) should be between 0 and 1. You may also assume that the weight entered by the instructor is valid (between 0 and 1). Similar to the previous operations, the system should rst check whether or not the course with the specied course id exists; if it does not, it should prevent to add a grade form and display a warning message. The form ids are unique within the same course so that two grade forms with the same id do not exist in the same course. Thus, you should also check whether or not this grade form has already been in the system. If this is the case, the system should prevent to add a grade form and display a warning message. Please note that, for a particular course, there can be more than one grade form. Thus, the studentreview-system should handle the cases where there are multiple grade forms for a single course. Delete a grade form: The student-review-system will allow the instructor to delete a particular grade form whose course id and form id are specied. If there is no course with the specied course id, the system should display a warning message. Similarly, if there is no grade form with the specied form id, the system should display a warning message. Show the list of courses: The student-review-system will allow the instructor to see a brief summary of all the courses she/he oers. This summary includes the course id, the course name, and the number of students that are registered to this course. Show detailed information about a particular course: The student-review-system will allow the instructor to enter a course id and see detailed information about this particular course. This detailed information includes: The course id, The course name, The number of students registered to this course, The number of exams given so far and their average, and The list of the students together with their grades. If the course does not exist (i.e., if there is no course with the specied course id), the system should display a warning message. Show detailed information about a particular student: The student-review-system will allow the instructor to enter a student id and see information about all courses that are taken by this particular student. For each course the student is taking, this information includes: The course id, The course name, All grades of the student in this course, and The weighted average of these grades. 2

Below is the required public part of the StudentReviewSystem class that you must write in this assignment. The name of the class must be StudentReviewSystem, and must include these public member functions. We will use these functions to test your code. The interface for the class must be written in a le called StudentReviewSystem.h and its implementation must be written in a le called StudentReviewSystem.cpp. You can dene additional public and private member functions and data members in this class. You can also dene additional classes in your solution. class StudentReviewSystem { public: StudentReviewSystem(); ~StudentReviewSystem(); void addCourse( const int courseId, const string courseName ); void deleteCourse( const int courseId ); void addStudent( const int courseId, const int studentId, const string studentName ); void dropStudent( const int courseId, const int studentId ); void addGradeForm( const int courseId, const int formId, const double weight ); void deleteGradeForm( const int courseId, const int formId ); void showAllCourses(); void showCourse( const int courseId ); void showStudent( const int studentId ); }; Here is an example test program that uses this class and the corresponding output. We will use a similar program to test your solution so make sure that the name of the class is StudentReviewSystem, its interface is in the le called StudentReviewSystem.h, and the required functions are dened as shown above. Example test code: #include <iostream> using namespace std; #include "StudentReviewSystem.h" int main() { StudentReviewSystem S; S.addCourse( 101, "Algorithms and Programming" ); S.addCourse( 201, "Fundamental Structures of Computer Science I" ); S.addCourse( 223, "Digital Design" ); S.addCourse( 224, "Computer Organization" ); S.addCourse( 201, "Fundamental Structures of Computer Science I" ); S.deleteCourse( 223 ); S.deleteCourse( 102 ); cout << endl; S.addStudent( S.addStudent( S.addStudent( S.addStudent( S.addStudent( 201, 201, 201, 201, 201, 1234, "Cigdem Gunduz Demir" ); 4567, "Aynur Dayanik" ); 891234, "Tunc Gultekin" ); 891234, "Can Fahrettin Koyuncu" ); 5678, "Gulden Olgun" ); 3

S.addStudent( 224, 1234, S.addStudent( 351, 3456, S.dropStudent( 224, 5678 S.dropStudent( 202, 5678 S.dropStudent( 201, 5678 cout << endl; S.addGradeForm( 201, 1, S.addGradeForm( 201, 2, S.addGradeForm( 201, 3, S.addGradeForm( 201, 1, S.addGradeForm( 224, 1, S.addGradeForm( 101, 1, S.addGradeForm( 351, 4, S.deleteGradeForm( 201, S.deleteGradeForm( 201, S.deleteGradeForm( 223, cout << endl; S.showAllCourses(); S.showCourse( 201 ); S.showCourse( 224 ); S.showCourse( 351 ); S.showStudent( 1234 );

"Cigdem Gunduz Demir" ); "Anil Armagan" ); ); ); );

0.4 ); 0.2 ); 0.1 ); 0.1 ); 0.4 ); 0.4 ); 0.5 ); 1 ); 4 ); 1 );

cout cout cout cout cout cout

<< << << << << <<

endl; endl; endl; endl; endl; endl;

cout cout cout cout cout

<< << << << <<

endl; endl; endl; endl; endl;

S.addStudent( 224, 4567, "Aynur Dayanik" ); S.addStudent( 224, 891234, "Tunc Gultekin" ); S.addStudent( 224, 5678, "Gulden Olgun" ); cout << endl; S.showCourse( 224 ); S.addGradeForm( 224, 2, 0.35 ); S.showCourse( 224 ); S.showStudent( 891234 ); S.dropStudent( 224, 891234 ); S.showStudent( 891234 ); S.showCourse( 224 ); S.deleteGradeForm( 224, 1 ); S.showCourse( 224 ); S.showStudent( 5678 ); return 0; } Output of the example test code: Course Course Course Course Course Course Course 101 201 223 224 201 223 102 has been added has been added has been added has been added already exists has been deleted does not exist cout cout cout cout cout cout cout << << << << << << << endl; endl; endl; endl; endl; endl; endl;

cout << endl; cout << endl;

Student 1234 has been added to Course 201 Student 4567 has been added to Course 201 4

Student 891234 has been added to Course 201 Student 891234 already exists in Course 201 Student 5678 has been added to Course 201 Student 1234 has been added to Course 224 Course 351 does not exist Student 5678 does not exist in Course 224 Course 202 does not exist Student 5678 has been dropped from Course 201 Enter the grades for Gradeform 1 for Course 201 Grade of student 1234: 100 Grade of student 4567: 98 Grade of student 891234: 67 Gradeform 1 has been added to Course 201 Enter the grades for Gradeform 2 for Course 201 Grade of student 1234: 90 Grade of student 4567: 100 Grade of student 891234: 78 Gradeform 2 has been added to Course 201 Enter the grades for Gradeform 3 for Course 201 Grade of student 1234: 80 Grade of student 4567: 95 Grade of student 891234: 45 Gradeform 3 has been added to Course 201 Gradeform 1 already exists in Course 201 Enter the grades for Gradeform 1 for Course 224 Grade of student 1234: 95 Gradeform 1 has been added to Course 224 No student is taking Course 101 Gradeform 1 has been added to Course 101 Course 351 does not exist Gradeform 1 has been deleted from Course 201 Gradeform 4 does not exist in Course 201 Course 223 does not exist 101 (Algorithms and Programming): 0 students registered 201 (Fundamental Structures of Computer Science I): 3 students registered 224 (Computer Organization): 1 students registered 201 (Fundamental Structures of Computer Science I) : 3 students registered and 2 exams given Exam 2 has an average of 89.3333 Student 1234 (Cigdem Gunduz Demir): 90 Student 4567 (Aynur Dayanik): 100 Student 891234 (Tunc Gultekin): 78 Exam 3 has an average of 73.3333 Student 1234 (Cigdem Gunduz Demir): 80 Student 4567 (Aynur Dayanik): 95 Student 891234 (Tunc Gultekin): 45 224 (Computer Organization) : 1 students registered and 1 exams given 5

Exam 1 has an average of 95 Student 1234 (Cigdem Gunduz Demir): 95 Course 351 does not exist Student 1234 is taking 2 courses Grades for Course 201 (Fundamental Structures of Computer Science I): 90 80 (weighted avg is 26) Grades for Course 224 (Computer Organization): 95 (weighted avg is 38) Student 4567 has been added to Course 224 Student 891234 has been added to Course 224 Student 5678 has been added to Course 224 224 (Computer Organization) : 4 students registered and 1 exams given Exam 1 has an average of 23.75 Student 1234 (Cigdem Gunduz Demir): 95 Student 4567 (Aynur Dayanik): 0 Student 891234 (Tunc Gultekin): 0 Student 5678 (Gulden Olgun): 0 Enter the grades for Gradeform 2 for Course 224 Grade of student 1234: 92 Grade of student 4567: 99 Grade of student 891234: 100 Grade of student 5678: 78 Gradeform 2 has been added to Course 224 224 (Computer Organization) : 4 students registered and 2 exams given Exam 1 has an average of 23.75 Student 1234 (Cigdem Gunduz Demir): 95 Student 4567 (Aynur Dayanik): 0 Student 891234 (Tunc Gultekin): 0 Student 5678 (Gulden Olgun): 0 Exam 2 has an average of 92.25 Student 1234 (Cigdem Gunduz Demir): 92 Student 4567 (Aynur Dayanik): 99 Student 891234 (Tunc Gultekin): 100 Student 5678 (Gulden Olgun): 78 Student 891234 is taking 2 courses Grades for Course 201 (Fundamental Structures of Computer Science I): 78 45 (weighted avg is 20.1) Grades for Course 224 (Computer Organization): 0 100 (weighted avg is 35) Student 891234 has been dropped from Course 224 Student 891234 is taking 1 courses Grades for Course 201 (Fundamental Structures of Computer Science I): 78 45 (weighted avg is 20.1) 224 (Computer Organization) : 3 students registered and 2 exams given Exam 1 has an average of 31.6667 Student 1234 (Cigdem Gunduz Demir): 95 Student 4567 (Aynur Dayanik): 0 Student 5678 (Gulden Olgun): 0 Exam 2 has an average of 89.6667 Student 1234 (Cigdem Gunduz Demir): 92 Student 4567 (Aynur Dayanik): 99 6

Student 5678 (Gulden Olgun): 78 Gradeform 1 has been deleted from Course 224 224 (Computer Organization) : 3 students registered and 1 exams given Exam 2 has an average of 89.6667 Student 1234 (Cigdem Gunduz Demir): 92 Student 4567 (Aynur Dayanik): 99 Student 5678 (Gulden Olgun): 78 Student 5678 is taking 1 courses Grades for Course 224 (Computer Organization): 78 (weighted avg is 27.3)

IMPORTANT NOTES: Do not start your homework before reading these notes!!! 1. You ARE NOT ALLOWED to modify the given parts of the header le. You MUST use dynamic arrays in your implementation. You will get no points if you use xed-sized arrays or data structures such as vector from the standard library. Similarly, you will get no points if you implement your homework using linked lists. Moreover, you ARE NOT ALLOWED to use any global variables. 2. However, if necessary, you may dene additional public and private data members and member functions in your class. You can also dene additional classes in your solution. 3. Your code must not have any memory leaks. You will lose points if you have memory leaks in your program even though the outputs of the operations are correct. 4. This assignment is due by 23:59 on Friday, November 22nd, 2013. You should upload your homework to the upload page (http://139.179.21.37/cs201/) before the deadline. This upload page will be available between November 18th and November 25th. No hardcopy submission is needed. The standard rules about late homework submissions apply. Please see the course syllabus for further discussion of the late homework policy as well as academic integrity. 5. In this assignment, you must have separate interface and implementation les (i.e., separate .h and .cpp les) for your class. We will test your implementation by writing our own driver .cpp le which will include your header le. For this reason, your class name MUST BE StudentReviewSystem and your les name MUST BE StudentReviewSystem.h and StudentReviewSystem.cpp. Note that you may write additional class(es) in your solution. You should put these two les (and any additional les if you wrote additional classes in your solution) in a single archive le (e.g., zip, tar, rar). The name of this zip le should conform the following name convention: secX-FirstnameLastname-StudentID.zip where X is your section number. The submissions that do not obey these rules will not be graded. 6. We also recommend you to write your own driver le to test each of your functions. However, you MUST NOT submit this test code (we will use our own test code). In other words, do not submit a le that contains a function called main 7. You are free to write your programs in any environment (you may use either Linux or Windows). On the other hand, we will test your programs on dijkstra.ug.bcc.bilkent.edu.tr and we will expect your programs to compile and run on the dijkstra machine. If we could not get your program properly work on the dijkstra machine, you would lose a considerable amount of points. Thus, we recommend you to make sure that your program compiles and properly works on dijkstra.ug.bcc.bilkent.edu.tr before submitting your assignment. 8. This homework will be graded by your TA Tunc Gultekin (tunc.gultekin at bilkent edu tr). Thus, you may ask your homework related questions directly to him.

You might also like