← Back to Miscellaneous
Question 167
Enum from int with helper method
Enum from int with helper method
Complete the static fromScore() method that maps an integer to a Rank enum constant, then read a score and print the result. Expected Output: Rank: SILVER In fromScore(): return BRONZE if score < 50, SILVER if score < 80, GOLD otherwise. This pattern centralizes enum-mapping logic in a single reusable method. ⚠️ AUTO-INPUT MODE: The input stream will automatically contain '72\n'. Use Scanner's nextInt() to read it.
Expected Output:
Rank: SILVER
Topics:
Miscellaneous
Code Editor
1
Tab to indent · Ctrl+Enter to run · 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.