Try the fastest way to create flashcards

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 GradedActivity array named grades as a field. The array should have four elements, one for each of the assignments previously described. The class should have the following methods:

setLab: \quad This method should accept a GradedActivity object as its argument. This object should already hold the student's score for the lab activity. Element 0 of the grades field should reference this object.

setPassfailexam: \quad This method should accept 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 field should reference this object. setEssay: \quad This method should accept an Essay object as its argument. (See Programming Challenge 4 for the Essay class. If you have not completed Programming Challenge 4 , use a GradedActivity object instead.) This object should already hold the student's score for the essay. Element 2 of the grades field should reference this object.

setFinalexam: \quad This method should accept a FinalExam object as its argument. This object should already hold the student's score for the final exam. Element 3 of the grades field should reference this object. tostring: \quad This method should return a string that contains the numeric scores and grades for each element in the grades array.

Demonstrate the class in a program.

Question

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
Answered 1 year ago
Answered 1 year ago
Step 1
1 of 12
//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 by Godfrey Muganda, Judy Walters, Tony Gaddis

Starting Out with C++ from Control Structures to Objects

8th EditionISBN: 9780133769395 (7 more)Godfrey Muganda, Judy Walters, Tony Gaddis
1,374 solutions
Fundamentals of Database Systems 7th Edition by Ramez Elmasri, Shamkant B. Navathe

Fundamentals of Database Systems

7th EditionISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe
948 solutions
Introduction to Algorithms 3rd Edition by Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

Introduction to Algorithms

3rd EditionISBN: 9780262033848Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
872 solutions
Introduction to Algorithms 4th Edition by Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

Introduction to Algorithms

4th EditionISBN: 9780262046305Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
945 solutions

More related questions

1/4

1/7