Overview For this assignment, implement and use the methods for a class called S
ID: 3867110 • Letter: O
Question
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: • 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 lowest quiz score 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 710. • 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 lowest quiz score. 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 200. 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 student's lowest quiz score, 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 setLow( int newLow ) This is a public method that makes a change to the data member that holds the lowest quiz score earned by the student. It takes 1 argument: an integer that holds a new lowest quiz score. It returns nothing. If the passed in argument is invalid (less than 0 or greater than the symbolic constant that holds the maximum lowest quiz score), display an error message that the lowest quiz score is invalid and set the data member that holds the lowest quiz score to 0. If the passed in argument is valid, use it to set the data member that holds the lowest quiz score. 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 - lowest quiz score that the student has earned) / ( the maximum number of exam points available + the maximum number of quiz points available - the low quiz score ) * 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 = 30% of the program average + 70% 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 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 667, quiz points earned of 106, lowest quiz of 10, and exam points earned of 186.50. • The second Student object should be created using the name "Pat Jones", program points earned of 574, quiz points earned of 53, lowest quiz of 0, and exam points earned of 110.50. • The third Student object should be created using the name "Chris Wilson", program points earned of 710, quiz points earned of 120, lowest quiz of 20, and exam points earned of 200. • 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 lowest quiz, 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 lowest quiz to 8, set the number of program points earned to 639, set the number of exam points earned to 111.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 setLow: argument is invalid Error in setExamPts: argument is invalid The first Student object Joe King Program Average: 93.94 Exam + Quiz Average: 94.17 Course Average: 94.10 Letter Grade: A The second Student object Pat Jones Program Average: 80.85 Exam + Quiz Average: 54.50 Course Average: 62.40 Letter Grade: F The third Student object Chris Wilson Program Average: 100.00 Exam + Quiz Average: 100.00 Course Average: 100.00 Letter Grade: A The fourth Student object Sandy Beach Program Average: 0.00 Exam + Quiz Average: 0.00 Course Average: 0.00 Letter Grade: F Sandy Beach Program Average: 90.00 Exam + Quiz Average: 70.17 Course Average: 76.12 Letter Grade: C Extra Credit For up to 5 points of extra credit, add code that will allow the user to enter data from the keyboard and use the input data to build a fifth student object. The user will be prompted to enter the first name, last name, program points earned, quiz points, lowest quiz score, and exam scores. Note that the constructor takes a student’s full name, so you must build the full name from the first name and the last name. Note about extra credit: the points will ONLY be awarded if the required portions of the assignment work correctly. In other words, don't take short cuts in the rest of the program because it is assumed that 5 extra points will be awarded. Extra Credit Output Enter student’s first name: Cari Enter student’s last name: Oky Enter the number of program points earned by the student: 710 Enter the number of quiz points earned by the student: 120 Enter the lowest quiz score earned by the student: 20 Enter the number of exam points earned by the student: 200 Cari Oky Program Average: 100.00 Exam + Quiz Average: 100.00 Course Average: 100.00 Letter Grade: A 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: • 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 lowest quiz score 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 710. • 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 lowest quiz score. 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 200. 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 student's lowest quiz score, 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 setLow( int newLow ) This is a public method that makes a change to the data member that holds the lowest quiz score earned by the student. It takes 1 argument: an integer that holds a new lowest quiz score. It returns nothing. If the passed in argument is invalid (less than 0 or greater than the symbolic constant that holds the maximum lowest quiz score), display an error message that the lowest quiz score is invalid and set the data member that holds the lowest quiz score to 0. If the passed in argument is valid, use it to set the data member that holds the lowest quiz score. 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 - lowest quiz score that the student has earned) / ( the maximum number of exam points available + the maximum number of quiz points available - the low quiz score ) * 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 = 30% of the program average + 70% 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 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 667, quiz points earned of 106, lowest quiz of 10, and exam points earned of 186.50. • The second Student object should be created using the name "Pat Jones", program points earned of 574, quiz points earned of 53, lowest quiz of 0, and exam points earned of 110.50. • The third Student object should be created using the name "Chris Wilson", program points earned of 710, quiz points earned of 120, lowest quiz of 20, and exam points earned of 200. • 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 lowest quiz, 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 lowest quiz to 8, set the number of program points earned to 639, set the number of exam points earned to 111.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 setLow: argument is invalid Error in setExamPts: argument is invalid The first Student object Joe King Program Average: 93.94 Exam + Quiz Average: 94.17 Course Average: 94.10 Letter Grade: A The second Student object Pat Jones Program Average: 80.85 Exam + Quiz Average: 54.50 Course Average: 62.40 Letter Grade: F The third Student object Chris Wilson Program Average: 100.00 Exam + Quiz Average: 100.00 Course Average: 100.00 Letter Grade: A The fourth Student object Sandy Beach Program Average: 0.00 Exam + Quiz Average: 0.00 Course Average: 0.00 Letter Grade: F Sandy Beach Program Average: 90.00 Exam + Quiz Average: 70.17 Course Average: 76.12 Letter Grade: C Extra Credit For up to 5 points of extra credit, add code that will allow the user to enter data from the keyboard and use the input data to build a fifth student object. The user will be prompted to enter the first name, last name, program points earned, quiz points, lowest quiz score, and exam scores. Note that the constructor takes a student’s full name, so you must build the full name from the first name and the last name. Note about extra credit: the points will ONLY be awarded if the required portions of the assignment work correctly. In other words, don't take short cuts in the rest of the program because it is assumed that 5 extra points will be awarded. Extra Credit Output Enter student’s first name: Cari Enter student’s last name: Oky Enter the number of program points earned by the student: 710 Enter the number of quiz points earned by the student: 120 Enter the lowest quiz score earned by the student: 20 Enter the number of exam points earned by the student: 200 Cari Oky Program Average: 100.00 Exam + Quiz Average: 100.00 Course Average: 100.00 Letter Grade: A 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: • 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 lowest quiz score 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 710. • 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 lowest quiz score. 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 200. 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 student's lowest quiz score, 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 setLow( int newLow ) This is a public method that makes a change to the data member that holds the lowest quiz score earned by the student. It takes 1 argument: an integer that holds a new lowest quiz score. It returns nothing. If the passed in argument is invalid (less than 0 or greater than the symbolic constant that holds the maximum lowest quiz score), display an error message that the lowest quiz score is invalid and set the data member that holds the lowest quiz score to 0. If the passed in argument is valid, use it to set the data member that holds the lowest quiz score. 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 - lowest quiz score that the student has earned) / ( the maximum number of exam points available + the maximum number of quiz points available - the low quiz score ) * 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 = 30% of the program average + 70% 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 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 667, quiz points earned of 106, lowest quiz of 10, and exam points earned of 186.50. • The second Student object should be created using the name "Pat Jones", program points earned of 574, quiz points earned of 53, lowest quiz of 0, and exam points earned of 110.50. • The third Student object should be created using the name "Chris Wilson", program points earned of 710, quiz points earned of 120, lowest quiz of 20, and exam points earned of 200. • 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 lowest quiz, 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 lowest quiz to 8, set the number of program points earned to 639, set the number of exam points earned to 111.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 setLow: argument is invalid Error in setExamPts: argument is invalid The first Student object Joe King Program Average: 93.94 Exam + Quiz Average: 94.17 Course Average: 94.10 Letter Grade: A The second Student object Pat Jones Program Average: 80.85 Exam + Quiz Average: 54.50 Course Average: 62.40 Letter Grade: F The third Student object Chris Wilson Program Average: 100.00 Exam + Quiz Average: 100.00 Course Average: 100.00 Letter Grade: A The fourth Student object Sandy Beach Program Average: 0.00 Exam + Quiz Average: 0.00 Course Average: 0.00 Letter Grade: F Sandy Beach Program Average: 90.00 Exam + Quiz Average: 70.17 Course Average: 76.12 Letter Grade: C Extra Credit For up to 5 points of extra credit, add code that will allow the user to enter data from the keyboard and use the input data to build a fifth student object. The user will be prompted to enter the first name, last name, program points earned, quiz points, lowest quiz score, and exam scores. Note that the constructor takes a student’s full name, so you must build the full name from the first name and the last name. Note about extra credit: the points will ONLY be awarded if the required portions of the assignment work correctly. In other words, don't take short cuts in the rest of the program because it is assumed that 5 extra points will be awarded. Extra Credit Output Enter student’s first name: Cari Enter student’s last name: Oky Enter the number of program points earned by the student: 710 Enter the number of quiz points earned by the student: 120 Enter the lowest quiz score earned by the student: 20 Enter the number of exam points earned by the student: 200 Cari Oky Program Average: 100.00 Exam + Quiz Average: 100.00 Course Average: 100.00 Letter Grade: AExplanation / Answer
OUTPUT:
PS F:my workschegg> ..exe
The first student object
Lily potter
Program Average 93.94
Exm + Quiz Average 94.17
Course Average 94.10
Letter Grade A
The second student object
Pat Jones
Program Average 80.85
Exm + Quiz Average 54.50
Course Average 62.40
Letter Grade D
The third student object
Chris Wilson
Program Average 100.00
Exm + Quiz Average 100.00
Course Average 100.00
Letter Grade A
The fourth student object
Input program points is invalid
Input quiz points is invalid
Input lowest quiz score is invalid
Input exm points is invalid
James Potter
Program Average 0.00
Exm + Quiz Average 0.00
Course Average 0.00
Letter Grade F
Updating student 4
James Potter
Program Average 90.00
Exm + Quiz Average 70.17
Course Average 76.12
Letter Grade C
Enter students first name:Cary
Enter students last name:Oky
Enter the number of program points earned by the student:710
Enter the number of quiz points earned by the student:120
Enter the lowest quiz score earned by the student:20
Enter the number of exm points earned by the student:200
Cary Oky
Program Average 100.00
Exm + Quiz Average 100.00
Course Average 100.00
Letter Grade A
Code:
#include <iostream>
#include <iomanip>
#include <string.h>
using namespace std;
class Student
{
private:
char name[50];
int pgmPts;
int quizPts;
int low;
double exmPts;
const int maxPgmPts;
const int maxQuizPts;
const int maxLow;
const int maxexmPts;
public:
Student() : maxPgmPts(710), maxQuizPts(120), maxLow(20), maxexmPts(200)
{
}
Student(char newName[50], int newPgmPts, int newQuizPts, int newLow, double newexmPts) : maxPgmPts(710), maxQuizPts(120), maxLow(20), maxexmPts(200)
{
strcpy(name, newName);
setPgmPts(newPgmPts);
setQuizPts(newQuizPts);
setLow(newLow);
setexmPts(newexmPts);
}
/**
Changes the data member that holds the number of program points that the student has earned
@param newPgmPts: new number of program points.
@return nothing
*/
void setPgmPts(int newPgmPts)
{
if (newPgmPts < 0 || newPgmPts > maxPgmPts)
{
pgmPts = 0;
cout << "Input program points is invalid" << endl;
}
else
{
pgmPts = newPgmPts;
}
}
/**
Changes the data member that holds the number of quiz points that the student has earned
@param newQuizPts: new number of quiz points.
@return nothing
*/
void setQuizPts(int newQuizPts)
{
if (newQuizPts < 0 || newQuizPts > maxQuizPts)
{
quizPts = 0;
cout << "Input quiz points is invalid" << endl;
}
else
{
quizPts = newQuizPts;
}
}
/**
Changes the data member that holds the lowest quiz score that the student has earned
@param newLow: new lowest quiz score
@return nothing
*/
void setLow(int newLow)
{
if (newLow < 0 || newLow > maxLow)
{
low = 0;
cout << "Input lowest quiz score is invalid" << endl;
}
else
{
low = newLow;
}
}
/**
Changes the data member that holds the exm points that the student has earned
@param newexmPts: new exm points
@return nothing
*/
void setexmPts(double newexmPts)
{
if (newexmPts < 0 || newexmPts > maxexmPts)
{
exmPts = 0;
cout << "Input exm points is invalid" << endl;
}
else
{
exmPts = newexmPts;
}
}
/**
Calculates program average
@param nothing
@return program average
*/
double calcPgmAverage()
{
double pgmAvg = ((double)pgmPts / (double)maxPgmPts) * 100;
return pgmAvg;
}
/**
Calculates exm and quiz average
@param nothing
@return exm and quiz average
*/
double calcexmAndQuizAverage()
{
double exmAndQuizAverage = (((double)(exmPts + quizPts - low)) / ((double)(maxexmPts + maxQuizPts - maxLow))) * 100;
return exmAndQuizAverage;
}
/**
Calculates course average
@param nothing
@return course average
*/
double calcCourseAverage()
{
double courseAverage = (0.30 * calcPgmAverage()) + (0.7 * calcexmAndQuizAverage());
return courseAverage;
}
/**
Calculates letter grade for the course
@param nothing
@return letter grade
*/
char letterGrade()
{
double courseAverage = calcCourseAverage();
char grade = 'F';
if (courseAverage >= 90.00 && courseAverage <= 100.00)
{
grade = 'A';
}
else if (courseAverage >= 80.00 && courseAverage < 90.00)
{
grade = 'B';
}
else if (courseAverage >= 70.00 && courseAverage < 80.00)
{
grade = 'C';
}
else if (courseAverage >= 60.00 && courseAverage < 70.00)
{
grade = 'D';
}
else
{
grade = 'F';
}
return grade;
}
void printStudent()
{
cout << name << endl;
cout << left << setw(25) << "Program Average";
cout << setprecision(2) << fixed << calcPgmAverage() << endl;
cout << left << setw(25) << "Exm + Quiz Average";
cout << setprecision(2) << fixed << calcexmAndQuizAverage() << endl;
cout << left << setw(25) << "Course Average";
cout << setprecision(2) << fixed << calcCourseAverage() << endl;
cout << left << setw(25) << "Letter Grade";
cout << setprecision(2) << fixed << letterGrade() << endl;
cout << endl;
}
};
int main()
{
char firstName[50], lastName[50], *name;
int pgmPts, quizPts, low;
double exmPts;
cout << " The first student object ";
Student student1((char *)"Lily potter", 667, 106, 10, 186.50);
student1.printStudent();
cout << " The second student object ";
Student student2((char *)"Pat Jones", 574, 53, 0, 110.50);
student2.printStudent();
cout << " The third student object ";
Student student3((char *)"Chris Wilson", 710, 120, 20, 200);
student3.printStudent();
cout << " The fourth student object ";
Student student4((char *)"James Potter", -5, 150, 30, 300);
student4.printStudent();
// update student 4
cout << "Updating student 4" << endl;
student4.setQuizPts(107);
student4.setLow(8);
student4.setPgmPts(639);
student4.setexmPts(111.50);
cout << " ";
student4.printStudent();
// For student 5
cout << " Enter students first name:";
cin >> firstName;
cout << " Enter students last name:";
cin >> lastName;
cout << " Enter the number of program points earned by the student:";
cin >> pgmPts;
cout << " Enter the number of quiz points earned by the student:";
cin >> quizPts;
cout << " Enter the lowest quiz score earned by the student:";
cin >> low;
cout << " Enter the number of exm points earned by the student:";
cin >> exmPts;
strcat(firstName, " ");
strcat(firstName, lastName);
Student student5(firstName, pgmPts, quizPts, low, exmPts);
student5.printStudent();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.