CSCI 240 - Assignment 12 - Fall 2007
Due: Thursday, May 3, 3 pm and no extensions
Points: 100
Overview
In this assignment you will implement a Student class with the same information as the structs in Assignment 11.. Each Student object will represent one student, but in addition to the data describing the student, it will include methods to create an instance of the class (a Student object), to display the information, to set values, and to decide whether to "accept", "deny", or "wait-list" the student.
You will also write a main() function to create two Student objects, and then to do certain things with them (modify, display, etc.). Details are given below.
The Student Class
This class will have (private) data members for the same information used in Assignment 11: last name, first name, id, GPA, and score.
You should not include any other data members in the class.
The Student class will implement a number of methods. They are short and simple. Details follow.
Student(char lastname[], char firstname[], char id[], double gpa, int score)
This is (obviously) the constructor. The arguments are obvious. They should be stored (copied) into the corresponding object data members. Use the various set methods described below to do the initializations. If GPA or score is invalid, display an error message and set the value to zero.
void showStudent()
This function will display the information in a Student object via cout:
Name: Joe Hill ID: Z021234 GPA: 3.25 Score: 1350
void setName(char newFirst[], char newLast[])
This function will change either first name, last name, or both. If the "null string" is passed for either argument, the corresponding data member will not be altered. No error checking need be done.
The null string can be supplied by passing the string literal "" to the function (that is, two double-quote chars with no space between them) or by supplying a char array with '\0' in ar[0].
void setID(char newID[])
This function will change the student's ID. No error checking need be done.
int setGPA(double newGPA)
This function will change the student's GPA. The value of newGPA must be between 0.0 and 4.0 (inclusive). If it is, make the change and return 1; if not do not change the GPA and return 0.
int setScore(int newScore)
This function will change the student's test score. The value of newScore must be between 200 and 1600 (inclusive). If it is, make the change and return 1; if not do not change the GPA and return 0.
char getDecision()
This function will determine the admission decision for the student.
If the GPA is equal to or above 3.5 or the test score is above 1300, return 'a' (for admit).
If the GPA is below 2.2 or the test score is below 900, return 'd' (for deny).
Otherwise, return 'w' (for wait-list).
The main() Function
Declare one Student with your name, your Z-ID, and some valid GPA and score.
Declare a second Student with some name, id, and an invalid GPA and invalid score. (You should see error messages from this Student's constructor. We will not use it any more in this program.)
Each step below should start with an informative label describing what the step should do and what will be displayed. Missing or poor labels will in a substantial point penalty. For the first (valid) Student:
1. Call showStudent()
2. Call setName() to change just the first name, then call showStudent()
again.
3. Call setName() again, changing both names, then call showStudent()
again.
4. Call setID() to change the ID, then call showStudent() again.
5. Call setScore() to change the score to a new valid score. Display the
value of the return code from the function. Then call showStudent()
again.
6. Call setScore() to change the score to a new invalid score.
Display the value of the return code from the function. Then call showStudent()
again.
7 and 8. Call setGPA() twice, once with a valid new GPA and once with an
invalid one. Each time, display the value of the return code from the function
and then call showStudent() again.
9. Call and display the result from getDecision(). (Note: we will
examine your code for getDecision(), so although you are only testing it
for one set of values, you must code the logic correctly for all three cases.)
That's all folks!
Hand in the usual. Remember, no extensions on this one.