Loading...
Loading...
A teacher types marks out of 100 into a grading tool. Typing mistakes happen, so marks below 0 or above 100 must be rejected. The grades are:
ABCDFPrint Grade X. For grade F, print a second line You failed. For marks outside 0 to 100, print only Invalid marks.
Invalid marks, or Grade X, followed by You failed on a second line for grade F.Example 1
Input
82
Output
Grade B
82 is between 75 and 89.
Example 2
Input
35
Output
Grade F You failed
Below 40 is a fail, so a second line is printed.
Example 3
Input
105
Output
Invalid marks
More than 100 is a typing mistake.
Try the problem first. Open one hint at a time.
Reject invalid marks first, so the grading ladder only sees 0 to 100.
In the ladder, test the highest band first: marks >= 90, then marks >= 75, and so on. Each test already knows the earlier ones failed.
The extra You failed line belongs only in the F branch.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor