Question

Design an Essay class that extends the GradedActivity class presented in the chapter 10 of textbook....

Design an Essay class that extends the GradedActivity class presented in the chapter 10 of textbook. The Essay class should determine the grade a student receives for an essay. The student’s essay score can be up to 100 and is determined in the following manner:
 Grammar: 30 points

 Spelling: 20 points

 Correct length: 20 points

 Content: 30 points
Demonstrate the class in a simple program.



Example Run
run:

Term paper:

Grammar points: 25.0

Spelling points: 18.0

Length points: 20.0

Content points: 25.0

Total points: 88.0

Grade: B

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ Program:

#include <iostream>

using namespace std;

/* Class already present in the chapter */
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
virtual double getScore() const
{ return score; }

virtual char getLetterGrade() const;
};

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

/* Essay class */
class Essay : public GradedActivity
{
   private:
       double grammerPts;
       double spellingPts;
       double lengthPts;
       double contentPts;

   public:
       // Default constructor
       Essay()
       {
           grammerPts = 0.0;
           spellingPts = 0.0;
           lengthPts = 0.0;
           contentPts = 0.0;
       }

       // Setter Methods
       void setGrammerPts(double pts)
       {
           // Validating points.
           if (pts < 0 || pts > 30)
           {
               // Invalid data
               cout << "\n Error!!! Not a valid value... \n";

               //Set value to 0
               grammerPts = 0;
           }
           else
           {
               // Assigning Value
               grammerPts = pts;
           }
       };

       void setSpellingPts(double pts)
       {
           // Validating points.
           if (pts < 0 || pts > 20)
           {
               // Invalid data
               cout << "\n Error!!! Not a valid value... \n";

               //Set value to 0
               spellingPts = 0;
           }
           else
           {
               // Assigning Value
               spellingPts = pts;
           }
       };

       void setLengthPts(double pts)
       {
           // Validating points.
           if (pts < 0 || pts > 20)
           {
               // Invalid data
               cout << "\n Error!!! Not a valid value... \n";

               //Set value to 0
               lengthPts = 0;
           }
           else
           {
               // Assigning Value
               lengthPts = pts;
           }
       };

       void setContentPts(double pts)
       {
           // Validating points.
           if (pts < 0 || pts > 30)
           {
               // Invalid data
               cout << "\n Error!!! Not a valid value... \n";

               //Set value to 0
               contentPts = 0;
           }
           else
           {
               // Assigning Value
               contentPts = pts;
           }
       };

       //Overriding setScore function
       void setScore()
       {
            GradedActivity::setScore(grammerPts + spellingPts + lengthPts + contentPts);
       }

       // Getter Methods
       double getGrammerPts(){ return grammerPts; }
       double getSpellingPts(){ return spellingPts; }
       double getLengthPts(){ return lengthPts; }
       double getContentPts(){ return contentPts; }
};

// Test Program
int main()
{
    Essay essayObj;
    double pts;

    // Reading Grammar Points
    cout << "\n Input grammar points(0-30): ";
    cin >> pts;

    //Storing using Essay class object
    essayObj.setGrammerPts(pts);


    // Reading Spelling Points
    cout << "\n Input spelling points(0-20): ";
    cin >> pts;

    //Storing using Essay class object
    essayObj.setSpellingPts(pts);


    // Reading Length Points
    cout << "\n Input correct length points(0-20): ";
    cin >> pts;

    //Storing using Essay class object
    essayObj.setLengthPts(pts);


    // Reading Content Points
    cout << "\n Input content points(0-30): ";
    cin >> pts;

    //Storing using Essay class object
    essayObj.setContentPts(pts);

    //Assigning total score
    essayObj.setScore();

    // Displaying results
    cout << "\n\n Total score: " << essayObj.getScore() << endl;
    cout << "\n\n Grade Obtained: " << essayObj.getLetterGrade() << endl;

    cout << "\n\n";
    return 0;

Add a comment
Know the answer?
Add Answer to:
Design an Essay class that extends the GradedActivity class presented in the chapter 10 of textbook....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • this is the essay.h file this is the gradedActivity.h file this is the gradeActivity.cpp file Can...

    this is the essay.h file this is the gradedActivity.h file this is the gradeActivity.cpp file Can someone help me write the code for this in c++. I'm really struggling with this. If you can include comments and a screenshot of the test run it would be greatly appreciated Part 1: Implement Essay.h and demonstrate the Essay class The Essay class is derived from the GradedActivity class presented in chapter 15. The Essay class determines the grade a student receives on...

  • The Microbiome is a central theme of our textbook. Every chapter you will see a section on microbiome related to the cha...

    The Microbiome is a central theme of our textbook. Every chapter you will see a section on microbiome related to the chapter contents. The purpose the discussion forums is to extend your learning and to deepen your understanding of concepts presented in the course. To contribute to this discussion forum: Watch the TED talk on our microbiome "Meet your Microbes" (Click on the link to watch the video)and write a short report (200-250 words, in your own words) on what...

  • Building a Case Study Analysis Choose an issue of international relevance on any of the topics:...

    Building a Case Study Analysis Choose an issue of international relevance on any of the topics: Week 3: Bitcoin, Tariffs and Subsidies, Global Institutions How to Build the Case Responses Find a minimum of three news articles discussing this issue. The articles should be news articles, written by journalists for publication in newspapers or on news, websites (cannot be blogs or commercial sites). They may also be transcripts of news stories that were broadcast on television or radio. The article...

  • In C++ Assignment 7 - Postal Packages In the Gaddis textbook read Chapter 8 sections 8.1-8.10...

    In C++ Assignment 7 - Postal Packages In the Gaddis textbook read Chapter 8 sections 8.1-8.10 and Chapter 9 section 9.1 before starting this assignment. Lone Star Package Service ships packages within the state of Texas. Packages are accepted for shipping subject to the following restrictions: Shipping requirements The package weight must not exceed 50 pounds. The package must not exceed 3 feet in length, width, or height. The girth of the package must not exceed 5 feet. The girth...

  • Please Use your keyboard (Don't use handwriting) *******Please re-write my answer I need new and unique...

    Please Use your keyboard (Don't use handwriting) *******Please re-write my answer I need new and unique answers, please. (Use your own words, don't copy and paste)***** Case Study 1: Should a Computer Grade Your Essays? Would you like your college essays graded by a computer? Well, you just might find that happening in your next course. In April 2013, EdX, a Harvard/MIT joint venture to develop massively open online courses (MOOCs), launched an essay-scoring program. Using artificial intelligence technology, essays...

  • Case Study 1: Should a Computer Grade Your Essays? Would you like your college essays graded...

    Case Study 1: Should a Computer Grade Your Essays? Would you like your college essays graded by a computer? Well, you just might find that happening in your next course. In April 2013, EdX, a Harvard/MIT joint venture to develop massively open online courses (MOOCs), launched an essay-scoring program. Using arti ficial intelligence technology, essays and short answers are immediately scored and feedback tendered, allowing students to revise, resubmit, and improve their grade as many times as necessary. The non-profit...

  • ------------------------------------------------------------------------------------------------------------ CODE ALREADY HAVE BELOW--------------------------------------------------------------------------------------- public class LinkedQueue<T>

    ------------------------------------------------------------------------------------------------------------ CODE ALREADY HAVE BELOW--------------------------------------------------------------------------------------- public class LinkedQueue<T> implements QueueADT<T> {    private int count;    private LinearNode<T> head;    private LinearNode<T> tail;               public LinkedQueue()    {        count = 0;        head = null;        tail = null;    }    @Override    public void enqueue(T element)    {        LinearNode<T> node = new LinearNode<T> (element);        if(isEmpty())            head = node;        else           ...

  • In this two-part assignment. Part 1: Illustration Illustrate a particular environmental agent and its effect on...

    In this two-part assignment. Part 1: Illustration Illustrate a particular environmental agent and its effect on the environment. You may use a flow chart, diagram, pictorial, or other instructor-approved format. The illustration should show: The vector-borne disease. The pathway or chain of the disease. The factors that contribute to the spread of the disease. The effect of the disease. Part 2: Narrative In a short narrative (750 words maximum), do the following: Identify the vector-borne disease. Explain in detail the...

  • CS 1181 - Lab 03 The due date for every lab assignment is found in the...

    CS 1181 - Lab 03 The due date for every lab assignment is found in the course’s Pilot drop box. POINTS: 10 PURPOSE: This lab will introduce you to Java’s framework for working with simple graphics, as well as the concept of an animation loop and dialog boxes for I/O. PROCEDURES: You are provided with a “starter” Project for this lab. Import this project file (In NetBeans Use File->Import->From Zip). CS1181BallPanel uses JavaFX to display an animation of two balls...

  • The both files are included. Where are these which are colorful. Point.h and point.cpp Hor this assignment you are provided the files for a class called point. Download the h and .cpp files and incl...

    The both files are included. Where are these which are colorful. Point.h and point.cpp Hor this assignment you are provided the files for a class called point. Download the h and .cpp files and include them in your project. IheじML diagram below details the class Point くくfriend>> ostream& operator.((ostream&, point&) <ごfriend::. İstream& operator:..イ1stream&-point& - : double - v doublc getX) double getYO double - sctX( double): void - set Y(double) : void - point(double-0.0, double-0.0 operator-(const point& bool perator< const...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT