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

Essay Class Design an Essay class that extends the GradedActivity(Shown below) c

ID: 3822156 • Letter: E

Question

Essay Class Design an Essay class that extends the GradedActivity(Shown below) class presented in this chapter. 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.

//GradedActivity Class

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package essaydemo;

/**
A class that holds a grade for a graded activity.
*/

public class GradedActivity
{
private double score; // Numeric score

/**
The setScore method sets the score field.
@param s The value to store in score.
*/

public void setScore(double s)
{
score = s;
}

/**
The getScore method returns the score.
@return The value stored in the score field.
*/

public double getScore()
{
return score;
}

/**
The getGrade method returns a letter grade
determined from the score field.
@return The letter grade.
*/

public char getGrade()
{
char letterGrade;

if (score >= 90)
letterGrade = 'A';
else if (score >= 80)
letterGrade = 'B';
else if (score >= 70)
letterGrade = 'C';
else if (score >= 60)
letterGrade = 'D';
else
letterGrade = 'F';

return letterGrade;
}
}

Explanation / Answer

Here is the code for you:

//package essaydemo;
public class Essay extends GradedActivity
{
    double grammarPoints;
    double spellingPoints;
    double lengthPoints;
    double contentPoints;
    public Essay(double gP, double sP, double lP, double cP)
        {
           super.setScore(gP + sP + lP + cP);
           grammarPoints = gP;
           spellingPoints = sP;
           lengthPoints = lP;
           contentPoints = cP;
        }
    public double getGrammarPoints() { return grammarPoints; }
    public double getSpellingPoints() { return spellingPoints; }
    public double getLengthPoints() { return lengthPoints; }
    public double getContentPoints() { return contentPoints; }
       
    public void setGrammarPoints(double gP) { grammarPoints = gP; }
    public void setSpellingPoints(double sP) { spellingPoints = sP; }
    public void setLengthPoints(double lP) { lengthPoints = lP; }
    public void setContentPoints(double cP) { contentPoints = cP; }
       
    public double getScore()
        {
           return grammarPoints + spellingPoints + lengthPoints + contentPoints;
        }
          
    public char getLetterGrade()
        {
           if(getScore() >= 90)
               return 'A';
           else if(getScore() >= 80)
               return 'B';
           else if(getScore() >= 70)
               return 'C';
           else if(getScore() >= 60)
               return 'D';
           else
               return 'F';              
        }
}

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