Name: _________________

 

Queens College, CS211                                                                       Instructors: Stuart Kern, John Donath

 

Quiz #1, Version F

 

Directions:  Answer the following questions on the quiz paper.  The quiz is open book, open notes.

 

Questions 1 and 2 involve a class Student.  The class should keep track of the student’s name as a c-string which can store at most 40 characters (remember that a c-string is an array of characters, terminated by ‘\0’, don’t forget to allocate space for the termination symbol), the student’s course id number as an integer, and year of birth as an int. 

The class should also have two functions: 

1. This function gets, as parameters, the student’s name as a c-string, gender as a character and the year of birth as an integer.  It then sets the name of the student stored in the class up to the first 40 letters in the parameter (if the name exceeds 40 characters), and creates an id number for the student, which it calculates by adding the student’s year of birth and the character value of the seventh letter in the student’s name.  If the student is male and the ID number is odd, the ID number should be multiplied by 4.  If the student is female, and the ID number is even, subtract 5 from it.  It stores the student’s id and age as part of the class.

2.  This function returns a bool that is false if the student is male, true if the student is female.  Remember that females have id numbers that are odd and males have id numbers that are even.

 

1.  Write the .h file for this class (3 points).

 

2.  Write the .cpp file for this class (3 points).