Need pseudocode and flowchart for the problem below Write th
Need pseudocode and flowchart for the problem below!
Write the pseudocode for 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 can be up to 100 and is determined in the following manner:
Grammar: up to 30 points
Spelling: up to 20 points
Correct length: up to 20 points
Content: up to 30 points
Once you have designed the class, design a program that prompts the user to enter the number of points that a student has earned for grammar, spelling, length, and content. Create an Essay object and store this data in the object. Use the object’s methods to get the student’s overall score and grade, and display this data on the screen.
GradedActivity
- score: Real
+ setScore(s:Real)
+ getScore():Real
+ getGrade():String
| GradedActivity |
| - score: Real |
| + setScore(s:Real) + getScore():Real + getGrade():String |
Solution
solution
public class GradeActivity {
protected double score;
protected String grade;
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
public String getGrade()
{
return grade;
}
public void setGrade(String grade)
{
this.grade =grade;
}
public String toString() {
return \"GradeActivity [score=\" + score + \", grade=\" + grade + \"]\";
}
}
********************************************************************************************************
import java.util.Scanner;
public class Essay extends GradeActivity {
/*
* Grammar: up to 30 points Spelling: up to 20 points Correct length: up to
* 20 points Content: up to 30 points
*/
private int grammarScore;
private int SpellingScore;
private int correctLengthScore;
private int contentScore;
public int getGrammarScore() {
return grammarScore;
}
public void setGrammarScore(int grammarScore) {
this.grammarScore = grammarScore;
}
public int getSpellingScore() {
return SpellingScore;
}
public void setSpellingScore(int spellingScore) {
SpellingScore = spellingScore;
}
public int getCorrectLengthScore() {
return correctLengthScore;
}
public void setCorrectLengthScore(int correctLengthScore) {
this.correctLengthScore = correctLengthScore;
}
public int getContentScore() {
return contentScore;
}
public void setContentScore(int contentScore) {
this.contentScore = contentScore;
}
public String toString() {
return \"Essay [grammarScore=\" + grammarScore + \", SpellingScore=\"
+ SpellingScore + \", correctLengthScore=\" + correctLengthScore
+ \", contentScore=\" + contentScore + \", score=\" + score
+ \", grade=\" + grade + \"]\";
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Essay essay = new Essay();
System.out.println(\"enter the grammer score upto 30\");
int grammarScore = scanner.nextInt();
essay.setGrammarScore(grammarScore);
System.out.println(\"enter the Spelling Score upto 20\");
int SpellingScore = scanner.nextInt();
essay.setSpellingScore(SpellingScore);
System.out.println(\"enter the correctLength score upto 20\");
int correctLengthScore = scanner.nextInt();
essay.setCorrectLengthScore(correctLengthScore);
System.out.println(\"enter the content score upto 30\");
int contentScore = scanner.nextInt();
essay.setContentScore(contentScore);
int totalScore = essay.getContentScore()
+ essay.getCorrectLengthScore() + essay.getGrammarScore()
+ essay.getSpellingScore();
essay.setScore(totalScore);
if (totalScore >= 90) {
essay.setGrade(\"A\");
}
if (totalScore >= 70 && totalScore < 90)
essay.setGrade(\"B\");
if (totalScore >= 50 && totalScore < 70)
essay.setGrade(\"C\");
if (totalScore == 0 && totalScore < 50)
essay.setGrade(\"D\");
System.out.println(\"the total score is\" + essay.getScore());
System.out.println(\"the grade of a student is\" + essay.getGrade());
}
}
**********************************************************************************
output
enter the grammer score upto 30
25
enter the Spelling Score upto 20
15
enter the correctLength score upto 20
15
enter the content score upto 30
25
the total score is80.0
the grade of a student isB


