CSCI 240 Spring 2015

Program 10
Classes
(100 points)


Due: Thursday, April 30 by 11:59 PM.

No late assignments will be accepted!

Overview

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

Student class

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

Data Members

The data members for the class are:

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:

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

  2. static const int MAX_PGM_PTS;

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

  4. 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.

Constructor

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.

Methods

void setPgmPts( int newPgmPts )

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.

void setQuizPts( int newQuizPts )

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.

void setSum2Low( int newSum2Low )

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.

void setExamPts( double newExamPts )

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.

double calcPgmAverage()

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

double calcExamAndQuizAverage()

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

double calcCourseAverage()

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

char letterGrade()

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.

void printStudent()

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.

main()

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

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.

Programming Notes

  1. Each method must have a documentation box like a function.

  2. Hand in a copy of your source code using Blackboard.

Output

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