Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions