Essay Class Need pseudocode and flowchart Design an Essay c

Essay Class - Need pseudocode and flowchart

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

//Eassy.java
//The class extends GradedActivity class
public class Eassy extends GradedActivity
{
   //declare instnace variables
   private int grammar;
   private int spelling;
   private int correctLength;
   private int content;

  
   //default construcor
   public Eassy()
   {
       grammar = 0;
       spelling = 0;
       correctLength = 0;
       content = 0;
   }

   //parameter construcor
   public Eassy(int grammar, int spelling,
           int correctLength, int content)
   {
       this.grammar = grammar;
       this.spelling = spelling;
       this.correctLength = correctLength;
       this.content = content;
   }

   void setGrammar(int grammar)
   {
       this.grammar = grammar;
   }

   void setSpelling(int spelling)
   {
       this.spelling = spelling;
   }

   void setCorrectLength(int correctLength)
   {
       this.correctLength = correctLength;
   }

   void setContent(int content)
   {
       this.content = content;
   }

   int getGrammarScore()
   {
       return grammar;
   }

   int getSpellingScore()
   {
       return spelling;
   }

   int getCorrectLengthScore()
   {
       return correctLength;
   }

   int getContentScore()
   {
       return content;
   }

   int getTotalScore()
   {
       return grammar + spelling + correctLength + content;
   }

   public String toString()
   {
       return \"Grammar : \" + grammar +
               \" pts.\ Spelling : \" + spelling +
               \" pts.\ Length : \"+ correctLength +
               \" pts.\ Content : \" + content + \" pts.\";
   }
}

------------------------------------------------------------------------------------------------

//GradedActivity.java
public class GradedActivity
{
   // instance variable
   private double score;

   //Method to set scores
   public void setScore(double score)
   {
       this.score = score;
   }

   //Method to return score
   public double getScore()
   {
       return score;
   }

   //Return grade letter based on score
   char getGrade()
   {
       char gradeLetter;

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

       return gradeLetter;
   }
}//end of class

------------------------------------------------------------------------------------------------


/*
*
* Test program
* */
//GradeTester.java
public class GradeTester {  
   public static void main(String[] args) {
       //Create an instance of Eassy
       Eassy compitition=new Eassy();
       compitition.setGrammar(30);
       compitition.setSpelling(20);;
       compitition.setCorrectLength(20);
       compitition.setContent(30);
      
       //Create an instance of GradedActivity
       GradedActivity ga=new GradedActivity();
       ga.setScore(compitition.getTotalScore());
      
       System.out.println(\"Points \");
       //print points
       System.out.println(compitition);
       System.out.println(\"Total Score :\");
       //print total score
       System.out.println(compitition.getTotalScore());
       System.out.println(\"Grade letter : \");
       //print grade
       System.out.println(ga.getGrade());
      
      
      
   }

}

------------------------------------------------------------------------------------------------

Sample Output:

Points
Grammar : 30 pts.
Spelling : 20 pts.
Length : 20 pts.
Content : 30 pts.
Total Score :
100
Grade letter :
A

Essay Class - Need pseudocode and flowchart Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determ
Essay Class - Need pseudocode and flowchart Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determ
Essay Class - Need pseudocode and flowchart Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determ
Essay Class - Need pseudocode and flowchart Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determ

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site