CJCoding With Joseph
15free / daySign inCreate account

Write an interface that has both kinds of method, and a class that implements it.

Requirements: 1. Scorable is an interface (not public) with an abstract method int score(). 2. Scorable also has a default method String grade(). It returns pass when score() is 50 or more, and fail otherwise. 3. Quiz implements Scorable. Its constructor is Quiz(int correct, int total): the number of correct answers and the number of questions. 4. Quiz supplies score() as a whole percentage: correct times 100, divided by total, using int arithmetic. 7 out of 10 is 70. 5. Quiz must not write its own grade(). It gets the default from the interface.

The tests also bring a class of their own that implements Scorable with only score(), so grade() has to live in the interface.

Do NOT write a main method.

Expected output

70 pass
40 fail

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
InterfacesClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.