CSCI 240 |
Spring 2015 |

Classes

(100 points)

For this assignment, implement and use the methods for a class called Student.

This class will represent a single student in the CSCI 240 class.

The data members for the class are:

a character array that holds a maximum of 50 characters and is used to hold the student's name

an integer that holds the number of program points earned by the student

an integer that holds the number of quiz points earned by the student

an integer that holds the sum of the two lowest quiz scores earned by the student

a double that holds the number of exam points earned by the student

an integer symbolic constant that holds the maximum number of program points available in the course. Use a value of 905.

an integer symbolic constant that holds the maximum number of quiz points available in the course. Use a value of 120.

an integer symbolic constant that holds the maximum sum of the two lowest quiz scores. Use a value of 20.

a double symbolic constant that holds the maximum number of exam points available in the course. Use a value of 300.

The symbolic constants need to be handled in a slightly different manner in this program than in previous programs. The issue with this program is that the symbolic constant is a member of the class, but a class definition does not take up any memory since it is just a pattern for what the class should contain. This means that there is no memory to store the values 905, 120, etc.... To solve this problem:

Within the class definition, define the symbolic constants with the keywords "static const" as part of the definition. For example:

Outside of the class definition, initialize the symbolic constant with a value.

static const int MAX_PGM_PTS;

const int Student::MAX_PGM_PTS = 905;

Note the inclusion of "Student::" in front of the constant name. This lets the compiler know that the constant belongs to the Student class.

This class has one constructor that should initialize the data member using the passed in arguments. It takes 5 arguments: a character array that holds the student's name, an integer that holds the number of program points the student has earned, an integer that holds the number of quiz points the student has earned, an integer that holds the sum of the student's two lowest quiz scores, and a double that holds the number of exam points that the student has earned.

The name data member should be initialized using the passed in argument and the strcpy function. The remaining numeric arguments should be initialized by calling the appropriate set access method and passing in the appropriate argument.

This is a ** public** method that makes a change to the
data member that holds the number of program points that the student
has earned. It takes 1 argument: an integer that holds a new number of
program points. It returns nothing.

If the passed in argument is invalid (less than 0 or greater than the symbolic constant that holds the maximum number of program points), display an error message that the number of program points is invalid and set the data member that holds the number of program points to 0. If the passed in argument is valid, use it to set the data member that holds the number of program points.

This is a ** public** method that makes a change to the
data member that holds the number of quiz points that the student
has earned. It takes 1 argument: an integer that holds a new number of
quiz points. It returns nothing.

If the passed in argument is invalid (less than 0 or greater than the symbolic constant that holds the maximum number of quiz points), display an error message that the number of quiz points is invalid and set the data member that holds the number of quiz points to 0. If the passed in argument is valid, use it to set the data member that holds the number of quiz points.

This is a ** public** method that makes a change to the
data member that holds the sum of the two lowest quiz scores earned by
the student. It takes 1 argument: an integer that holds a new sum of the
two lowest quiz scores. It returns nothing.

If the passed in argument is invalid (less than 0 or greater than the symbolic constant that holds the maximum sum of the two lowest quiz scores), display an error message that the sum of the two lowest quiz scores is invalid and set the data member that holds the sum of the two lowest quiz scores to 0. If the passed in argument is valid, use it to set the data member that holds the sum of the two lowest quiz scores.

This is a ** public** method that makes a change to the
data member that holds the number of exam points that the student
has earned. It takes 1 argument: a double that holds a new number of
exam points. It returns nothing.

If the passed in argument is invalid (less than 0 or greater than the symbolic constant that holds the maximum number of exam points), display an error message that the number of exam points is invalid and set the data member that holds the number of exam points to 0. If the passed in argument is valid, use it to set the data member that holds the number of exam points.

This is a ** public** method that returns the calculated
program average for a student. It takes no argument. It returns a double,
which is the calculated program average.

The program average is calculated by using the following formula:

Program Average = number of program points that the student has earned / the maximum number of program points available * 100

This is a ** public** method that returns the calculated
exam and quiz average for a student. It takes no argument. It returns a
double, which is the calculated exam and quiz average.

The exam and quiz average is calculated by using the following formula:

Exam and Quiz Average = ( number of exam points that the student has earned + number of quiz points that the student has earned - sum of the two lowest quiz scores that the student has earned) / ( the maximum number of exam points available + the maximum number of quiz points available - the maximum sum of the two lowest quiz scores ) * 100

This is a ** public** method that returns the calculated
course average for a student. It takes no argument. It returns a double,
which is the calculated course average.

The course average is calculated by using the following formula:

Course Average = 35% of the program average + 65% of the exam and quiz average

This is a ** public** method that will determine the student's
letter grade for the course. It takes no argument. It returns a character:
the student's letter grade.

A student's letter grade is based on their course average. If the course average is greater than or equal to 90.00 and less than or equal to 100.00, then the student earned an A. If the course average is greater than or equal to 80.00 and less than 90.00, the student earned a B. If the course average is greater than or equal to 70.00 and less than 80.00, the student earned a C. If the course average is greater than or equal to 60.00 and less than 70.00, the student earned a D. If the course average is less than 60.00, the student earned a F.

There is one exception to the how the letter grade is determined and that's if the student didn't pass both portions of the course (ie. they didn't receive a program average greater than or equal to 55% or they didn't receive an exam and quiz average greater than or equal to 55%). If this is the case, then the student earned a F.

This is a ** public** method that will display the student's
course information. It takes no argument. It returns nothing.

For the student, display the student's name, calculated program average, calculated exam and quiz average, course average, and letter grade. The averages should be formatted with exactly two digits after the decimal point. The format of the student's information, excluding the number of digits after the decimal point for the averages, is left up to you but it must be neat and easily readable.

In main(), create 4 Student objects. They should contain the values:

The first Student object should be created using your name (if you're doing pair programming, then it should have use both of your names "Billy B/Sally S"), program points earned of 767, quiz points earned of 106, sum of the two lowest quizzes of 10, and exam points earned of 286.50.

The second Student object should be created using the name "Peter Laviolette", program points earned of 474, quiz points earned of 53, sum of the two lowest quizzes of 0, and exam points earned of 218.50.

The third Student object should be created using the name "Joel Quenneville", program points earned of 905, quiz points earned of 120, sum of the two lowest quizzes of 20, and exam points earned of 300.

The fourth Student object should be created using any name you want, an invalid number of program points earned, an invalid number of quiz points earned, an invalid sum of the two lowest quizzes, and an invalid number of exam points.

The rest of main() will include using the various methods on each of the Student objects. Display a label similar to "The first Student object" before anything is outputted for each of the objects.

For the first student, display their information.

For the second student, display their information.

For the third student, display their information.

For the fourth student, display their information, set the number of quiz points to 107, set the sum of the two lowest quizzes to 8, set the number of program points earned to 639, set the number of exam points earned to 211.50, and then display their information again.

Each method must have a documentation box like a function.

Hand in a copy of your source code using Blackboard.

Remember that the names for the first and fourth student will be different in your output, but the averages and letter grades should be the same as below.

Error in setPgmPts: argument is invalid Error in setQuizPts: argument is invalid Error in setSum2Low: argument is invalid Error in setExamPts: argument is invalid The first Student object Amy Byrnes Program Average: 84.75 Exam + Quiz Average: 95.63 Course Average: 91.82 Letter Grade: A The second Student object Peter Laviolette Program Average: 52.38 Exam + Quiz Average: 67.88 Course Average: 62.45 Letter Grade: F The third Student object Joel Quenneville Program Average: 100.00 Exam + Quiz Average: 100.00 Course Average: 100.00 Letter Grade: A The fourth Student object Ken Hitchcock Program Average: 0.00 Exam + Quiz Average: 0.00 Course Average: 0.00 Letter Grade: F Ken Hitchcock Program Average: 70.61 Exam + Quiz Average: 77.63 Course Average: 75.17 Letter Grade: C