Loading...
Loading...
A school prints one result line per student, but each exam grades differently. A normal exam gives PASS from 35 marks, else FAIL. An olympiad gives GOLD from 90, SILVER from 75, else PARTICIPATION. A scholarship test gives SELECTED from 85, else NOT_SELECTED. Write Exam with a result(name, marks) method that prints the line and calls grade(marks); children override only grade.
NORMAL, OLYMPIAD or SCHOLARSHIP), a one-word name and the marks.<name> <marks> <grade> for each student, then Top <name> for the highest marks (the first one listed on a tie).Example
Input
4 NORMAL Rohan 41 OLYMPIAD Diya 94 OLYMPIAD Arjun 75 SCHOLARSHIP Kavya 84
Output
Rohan 41 PASS Diya 94 GOLD Arjun 75 SILVER Kavya 84 NOT_SELECTED Top Diya
Arjun has exactly 75, which is SILVER; Kavya misses 85 by one.
Try the problem first. Open one hint at a time.
result stays in Exam. Inside it, grade(marks) is called on the current object, so the child's version runs.
For the top student keep the best marks and the name; replace them only when marks are strictly higher.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor