Checked Exception and throws
mediumQuestion 219Create a checked exception and use it:
1. Define InsufficientFundsException that extends Exception with a constructor that accepts a message string.
2. Write withdraw(double balance, double amount) throws InsufficientFundsException — throw the exception with message "Not enough funds" if amount > balance.
3. In main, read balance and amount. Call withdraw, print "Withdrawal successful" or "Error: " + e.getMessage() if caught.
Because InsufficientFundsException extends Exception (not RuntimeException), withdraw must declare throws.
⚠️ AUTO-INPUT MODE: The input stream will automatically contain a balance and an amount, for example '50.0 100.0\n'. Your code is also run with a balance that covers the amount, so both messages must work.
Expected output
Error: Not enough funds= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...