Question: Question 5 Complete the missing method implementation in the following Result class so that the following program run produces the output as mentioned below: Total

Question 5 Complete the missing method implementation in the following Result class so that the following program run produces the output as mentioned below:

Total = 82.5 Grade is Pass

public class Result implements Gradable { double total; //constructor

public Result(double total) { this.total = total;

}

/* Implement the method available from the implementing interface (Gradable) to print appropriate grade based on the following:

The grade is Pass when the total is more than or equal to 50 and it (grade) is Fail if the total is less than 50 */

//Missing method has to be completed

//toString method

@Override

public String toString() { return "Total = " + total + " Grade is "+calculateGrade();

}

public static void main(String [] args){ Result myMarks = new Result(82.5);

System.out.println(myMarks);

}

}

interface Gradable{

String calculateGrade();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!