Write the PSEUDOCODEALGORITHM for an Essay class that extend

Write the PSEUDOCODE/ALGORITHM 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


public class GradeActivity {
   int score;
   char grade;
   GradeActivity(){
      
   }
   GradeActivity(int score){
       setscore(score);
      
   }
   private void setscore(int score) {
       this.score=score;
      
   }
   public int getscore(){
       return score;
   }
   public void getgrade(){
       if(score>80&&score<=100)
           grade=\'a\';
       else if(score>75 && score<=79)
           grade=\'b\';
       else if(score>65 &&score <=74)
           grade=\'c\';
       else if(score>50 &&score<=64)
           grade=\'e\';
       else if(score>100)
           System.out.println(\"invalid points:\");
           else
           grade=\'f\';
       System.out.println(\"grade obtainde is:\"+grade);
       }
   }
class Essay extends GradeActivity{
   int grammer;
   int spelling;
   int length;
   int content;
   int score=0;
   char grade;
   Essay(){
      
   }
   Essay(int grammer,int spelling,int length,int content){
       setgrammer(grammer);
       setspelling(spelling);
       setlength(length);
       setcontent(content);
      
   }
   public void setcontent(int content) {
       this.content=content;
      
   }
   public void setlength(int length) {
       // TODO Auto-generated method stub
       this.length=length;
      
   }
   public void setspelling(int spelling) {
       // TODO Auto-generated method stub
       this.spelling=spelling;
      
   }
   public void setgrammer(int grammer) {
       // TODO Auto-generated method stub
       this.grammer=grammer;
      
   }
   public int getgrammer(){
       return grammer;
   }
   public int getlength(){
       return length;
   }
   public int spelling(){
       return spelling;
   }
   public int getcontent(){
       return content;
   }
   public void setscore(){
       score=(grammer+content+spelling+length);
       if(score>80&&score<=100)
           grade=\'a\';
       else if(score>75 && score<=79)
           grade=\'b\';
       else if(score>65 &&score <=74)
           grade=\'c\';
       else if(score>50 &&score<=64)
           grade=\'e\';
           else
           grade=\'f\';
       System.out.println(\"overall score is:\"+score);
       System.out.println(\"grade he obtainde is:\"+grade);
       }
      
      
   }
  

import java.util.Scanner;
public class example {


public static void main(String[] args) {
   Scanner sc=new Scanner(System.in);
   System.out.println(\"please enter your choice:\ 1.find grade to overallsocre \ 2.individal marks to enter\");
   int ch=sc.nextInt();
   if(ch==2){
   System.out.println(\"enter points for grammer:\");
   int g=sc.nextInt();
   System.out.println(\"enter points for spelling:\");
   int s=sc.nextInt();
   System.out.println(\"enter points for length:\");
   int l=sc.nextInt();
   System.out.println(\"enter points for content:\");
   int c=sc.nextInt();
  
   Essay e=new Essay(g,s,l,c);
   e.setscore();
   }else if(ch==1){
       System.out.println(\"enter score:\");
       int s=sc.nextInt();
   GradeActivity z=new GradeActivity(s);
   z.getgrade();
   }else
       System.exit(0);
  
}

}

output:
please enter your choice:
1.find grade to overallsocre
2.individal marks to enter
2
enter points for grammer:
32
enter points for spelling:
43
enter points for length:
12
enter points for content:
3
overall score is:90
grade he obtainde is:a

Write the PSEUDOCODE/ALGORITHM for an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determine the grade a
Write the PSEUDOCODE/ALGORITHM for an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determine the grade a
Write the PSEUDOCODE/ALGORITHM for an Essay class that extends the GradedActivity class presented in this chapter. The Essay class should determine the grade a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site