Custom Exception: Exception Class for Business Logic
Problem Description
Custom Exception: Exception class for Business Logic
In this problem, you will create a program that implements an InsufficientFundsException custom exception class, processes a bank account withdrawal for a specified amount, and displays the result to standard output.
Learning Objective: Create custom exception class for business-appropriate exception handling
Create InsufficientFundsException to represent bank account insufficient funds. When the balance is sufficient, perform the withdrawal; when it is not, throw the custom exception with a message containing the required amount and the available balance.
Input
Line 1: Initial balance
Line 2: Withdrawal amount
Output
Success: Withdrawn: [amount], Balance: [balance]
Insufficient: Insufficient funds: required [needed], available [balance]
Example
Input:
1000
500
Output:
Withdrawn: 500, Balance: 500
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up