Name: _____________________ September 23, 2003
Queens College, CS211 Instructor: Yosef Alayev
Quiz #1, Version D
Directions: Answer the question by writing code to solve the following problem. You should answer this quiz directly on the paper, using a pen. If you need extra space, you may use a sheet of your own paper. However, please make sure that any extra paper that you submit has your name written on every page, and is stapled to the quiz.
Note: This quiz is open book/open notes
For this quiz, you will be asked to design (declare) and implement (define) a class, Course, that models certain properties of the object course. You will also be asked to write a function that uses this course in the way described below:
1. Write a complete .h file for the class Course. It should contain a course name (string), department (string), and code (an integer). In addition, it should have a constructor that can set all the variable values, accessor functions for all three variables, a mutator function for the code, a function that returns, as a string the level of the course (see further description below) and any other required functions.
2. Write portions of the .cpp file for this class, implementing the following functions:
A: The 3 parameter constructor
B: The accessor function for the course name
C: The function that returns the level of the course. The level of the course should be a string, and be based on the course number: It should be determined as follows
If the course code is: The level is:
0-199 Freshman
200-299 Sophomore
300-599 Junior / Senior
600-899 Graduate
It is not required for you to provide code for the other functions in the .cpp file.
3. Write a function that accepts as its parameters an array of courses and the length of the array. It returns the number of courses that are graduate level.