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

//Chapter 15 Program Challenge06 #include <iostream> using namespace std; // Gra

ID: 3614209 • Letter: #

Question

//Chapter 15 Program Challenge06

#include <iostream>
using namespace std;
// GradedActivity class declaration
//*******************************************************
//this is the base class note: can change acessors & mutatorsif needed
//*********************************************************
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;
};

//************************************************************
//this class needs to be derived from Graded Activity
//************************************************************
class Essay
{
private:
   doublegrammar;          //To hold the score for grammar
   doublespelling;         // Tohold the score for spelling
   double correctLength;   // To hold the scorefor correctlength
   doublecontent;         // To holdthe score for content
  
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;
};

//******************************************************
//this needs to be deleted or changed to use getLetterGradebelow    
//******************************************************

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;
}

//*******************************************************
//need to use this for grade insted of above
//*******************************************************
char GradedActivity::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()//beginning ofmain***************************************************
{
   double gr;       // Tohold a score for gramamr
   double sp;      // To hold ascore for spelling
   double colg; // To hold a score forcorrectlength
   double con;       // To hold a score for content

   // Create a GradedActivity object for the test.
   Essay es;
do
{
    // Get a numeric test score from the user.
    cout << "Enter your score for Grammar :";
    cin >> gr;
    cout << "Enter your score for Spelling:";
    cin >> sp;
    cout << "Enter your score for CorrectLength: ";
    cin >> colg;
    cout << "Enter your score for Content:";
    cin >> con;
    if ((gr + sp + colg + con) > 100)
       cout << "Total is over100, check scores and re-enter " << endl;
   }while ((gr + sp + colg + con) > 100);

   // Store the numeric score in the test object.
   es = Essay(gr, sp, colg, con);
cout << endl;
   // Display the letter grade for the test.
   cout << "The grade for that test is: "
        <<es.getGradeEssay() << endl;
       
system("pause");
   return 0;
} //end ofmain*****************************************************************

Explanation / Answer

I've answered my own question, post closed