Design an Essay class that extends the GradedActivity class presented in this ch
ID: 3633500 • Letter: D
Question
Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determine the grade a student receives for an essay. The student's essay score be up tp 100 and is determined in the following manner:Grammer: 30 points
Spelling: 20 points
Correct length: 20 points
Content: 30 points
- Create a EssayDemo class that does the following:
Create an Essay object using the default constuctor. Assign scores to the object : Grammer: 30 points
Spelling: 20 points
Correct length: 20 points
Content: 30 points
(The output should display the score details mentioned above along with total points and letter grade, whereby 90-100 = A, 80-89 = B, 70-79 = C, 60-69 = D, <60 = F.)
- Create a GradedActivity class with the following methods: setScore, getScore, getGrade.
- Create a derived class of GradedActivity called Essay with the following methods: set Score- sets points for grammer, spelling, length, and content(This method overloads the super class method)
Make the following 4 methods private:
setGrammer- sets the grammer points.
setSpelling - sets the spelling points
setCorrectLength- sets the points for correct length
setContent- sets the points for content
Make the following 4 methods public:
getGrammer, getSpelling, getCorrectLength, getContent, getScore
Explanation / Answer
import java.util.Scanner; public class GradedActivity { private double score; public void setScore(double s) { score = s; } public double getScore() { return score; } 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; } } public class Essay extends GradedActivity { private double grammar; private double spelling; private double correctLength; private double content; public void setScore(double gr, double sp, double len, double cnt) { setGrammar(gr); setSpelling(sp); setCorrectLength(len); setContent(cnt); super.setScore(grammar + spelling + correctLength + content); } private void setGrammar(double g) { if (gRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.