CJCoding With Joseph
15per day

Validate Score with Custom Exception

Build a score validation system from scratch:
1. Create InvalidScoreException that extends RuntimeException with a message constructor.
2. Write validateScore(int score) that throws InvalidScoreException with the message "Score out of range: " + score if score is less than 0 or greater than 100.
3. In main, read a score, call validateScore, print "Score accepted" if valid, or print e.getMessage() if caught.

⚠️ AUTO-INPUT MODE: The input stream will automatically contain '150\n'.

Expected Output:

Score out of range: 150
Topics:
Miscellaneous
📥 Auto-Input:
150\n
This input is automatically fed to your program's stdin
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.