Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design an Essayclass that is derived fromthe GradedActivity class presented in t

ID: 3614020 • Letter: D

Question

Design an Essayclass that is derived fromthe GradedActivity class presented in

this chapter. The Essay class should determine thegrade a student receives on an

essay. The student’s essay score can be up to 100,and is determined in the following

manner:

Grammar: 30points

Spelling: 20points

Correct length: 20points

Content: 30points

// This program demonstrates theGradedActivity class.
#include <iostream>
using namespace std;

// GradedActivity classdeclaration

class GradedActivity
{
private:
   double score;   // To hold the numericscore
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; }
  
   char getLetterGrade() const;
};

//******************************************************
// Member functionGradedActivity::getLetterGrade      *
//******************************************************

charGradedActivity::getLetterGrade() const
{
   char letterGrade; // To hold the letter grade
  
   if (score > 89)
      letterGrade = 'A';
   else if (score > 79)
      letterGrade = 'B';
   else if (score > 69)
      letterGrade = 'C';
   else if (score > 59)
      letterGrade = 'D';
   else
      letterGrade = 'F';
  
   return letterGrade;
}
int main()
{
   double testScore; // To hold a test score
  
   // Create a GradedActivity object for the test.
   GradedActivity test;
  
   // Get a numeric test score from the user.
   cout << "Enter your numeric test score: ";
   cin >> testScore;
  
   // Store the numeric score in the test object.
   test.setScore(testScore);
  
   // Display the letter grade for the test.
   cout << "The grade for that test is "
        <<test.getLetterGrade() << endl;
system("pause");
   return 0;
}

Explanation / Answer

#include using namespace std; // Essay class declaration class Essay { public:    double grammar;   // To hold the score forgrammar    double spelling;   // To hold the score forspelling    double correctlength;   // To hold the scorefor correctlength    double content;   // To hold the score forcontent public:    // Default constructor    Essay()       {   grammar   = 0.0;        spelling= 0.0;        correctlength= 0.0;        content   =0.0;        }    // Constructor    Essay(double g, double s, double cl, double c)       {   grammar   = g;        spelling= s;        correctlength=cl;        content   =c;        }    char getGradeEssay() const; }; //****************************************************** // Member functionEssay::getGradeEssay      * //****************************************************** char Essay::getGradeEssay() const {    char letterGrade; // To hold the lettergrade    double score = grammar + spelling +correctlength + content;    if (score > 89)       letterGrade = 'A';    else if (score > 79)       letterGrade = 'B';    else if (score > 69)       letterGrade = 'C';    else if (score > 59)       letterGrade = 'D';    else       letterGrade = 'F';    return letterGrade; } //******************************************************** //******************************************************** int main() {    double grammar; // To hold a score forgramamr    double spelling; // To hold a score forspelling    double correctlength; // To hold a score forcorrectlength    double content; // To hold a score forcontent    // Create a GradedActivity object for the test.    Essay es;    // Get a numeric test score from the user.    cout > grammar;     cout > spelling;     cout > correctlength;     cout > content;    // Store the numeric score in the test object.    es = Essay(grammar, spelling, correctlength,content);    // Display the letter grade for the test.    cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote