CJCoding With Joseph
15free / daySign inCreate account

The finally Block Always Runs

Read an integer and print Parsed: <n>. If the input is not a number, catch the FormatException and print Bad input. Add a finally block that always prints Done, whether or not an exception happened. Use top-level statements with try/catch/finally.

Input 7 prints the output shown in Expected Output.

Input xyz prints:
Bad input
Done

Expected Output:

Parsed: 7
Done

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
Exceptions
📥 Auto-Input:
7\n
This input is automatically fed to your program's stdin
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.