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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started