019-006-004

Custom Exception: Exception Class for Business Logic

Medium

Problem Description

Custom Exception: Exception Class for Business Logic

Learning Objective: Create custom exception class for business-appropriate exception handling

Create InsufficientFundsException to represent bank account insufficient funds.

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
```java
Output:
```java
Withdrawn: 500, Balance: 500

Test Cases

※ Output examples follow programming industry standards

Input:
1000
500
Expected Output:
Withdrawn: 500, Balance: 500
Input:
100
200
Expected Output:
Insufficient funds: required 200, available 100
Input:
500
500
Expected Output:
Withdrawn: 500, Balance: 0
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 9 free executions remaining