← Back to Exceptions
Question 759
Handle Invalid Number Format
Handle Invalid Number Format
Read one line of input and parse it to anintwithint.Parse, then printNumber: <n>. If the text is not a valid integer,int.Parsethrows aFormatException— catch it and print exactlyNot a number. Use top-level statements withtry/catch. Input42prints: Number: 42 Inputabcprints: Not a number
Expected Output:
Number: 42= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Exceptions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.