Related questions with answers
In a course, a teacher gives the following tests and assignments: - A lab activity that is observed by the teacher and assigned a numeric score. - A pass/fail exam that has 10 questions. The minimum passing score is 70. - An essay that is assigned a numeric score. - A final exam that has 50 questions. Write a class named CourseGrades. The class should have a member named grades that is an array of GradedActivity pointers. The grades array should have four elements, one for each of the assignments previously described. The class should have the following member functions: setLab: This function should accept the address of a GradedActivity object as its argument. This object should already hold the student’s score for the lab activity. Element 0 of the grades array should reference this object. setPassFailExam: This function should accept the address of a PassFailExam object as its argument. This object should already hold the student’s score for the pass/fail exam. Element 1 of the grades array should reference this object. setEssay: This function should accept the address of an Essay object as its argument. (See Programming Challenge 6 for the Essay class. If you have not completed Programming Challenge 6, use a GradedActivity object instead.) This object should already hold the student’s score for the essay. Element 2 of the grades array should reference this object. setPassFailExam: This function should accept the address of a FinalExam object as its argument. This object should already hold the student’s score for the final exam. Element 3 of the grades array should reference this object. print: This function should display the numeric scores and grades for each element in the grades array. Demonstrate the class in a program.
Solution
Verified//contents of GradedActivity.h
//taken as is from the student folder
//and then modified
#ifndef GRADEDACTIVITY_H
#define GRADEDACTIVITY_H
// GradedActivity class declaration
class GradedActivity
{
protected:
double score; // To hold the numeric score
public:
// Default constructor
GradedActivity()
{ score = 0.0; }
// Constructor
GradedActivity(double s)
{ score = s; }
// Mutator function
void setScore(double s)
{ score = s; }
// Accessor functions
double getScore() const
{ return score; }
//****************************************
// MODIFICATION
// make function getLetterGrade virtual
// so that it gives the correct letter
// grade if the GradedActivity pointer
// points to a Pass/Fail Activity
// (which can receive P or F), or
// if it points to any other
// object that is graded with A, B, C...
virtual char getLetterGrade() const;
//****************************************
};
#endif
Create a free account to view solutions
Create a free account to view solutions
Recommended textbook solutions

Starting Out with C++ from Control Structures to Objects
8th Edition•ISBN: 9780133769395 (7 more)Godfrey Muganda, Judy Walters, Tony Gaddis
Fundamentals of Database Systems
7th Edition•ISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe
Introduction to Algorithms
3rd Edition•ISBN: 9780262033848Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
Introduction to Algorithms
4th Edition•ISBN: 9780262046305Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. CormenMore related questions
- computer science
- computer science
1/4
- computer science
- computer science
1/7