019-004-001

Exception Propagation: Point Usage Validation System

Easy

Problem Description

Exception Propagation: Point Usage Validation System

Learning Objective: Learn to understand how exceptions propagate through method calls

Create system to validate point card usage points. When usage points exceed balance points, throw IllegalArgumentException in validatePointUsage() method, and learn how exception propagates through usePoints() method to main() method. Without explicitly throwing, exception automatically propagates to caller.

Input

Line 1: Balance points
Line 2: Usage points

Output

=== Point Usage Validation ===
Balance: [balance]pt
Usage: [usage]pt
Validation: Success
━━━━━━━━━━━━━━━━
Status: Points used successfully
```java

Or when exception occurs:
```java
=== Point Usage Validation ===
Balance: [balance]pt
Usage: [usage]pt
Validation: Failed
━━━━━━━━━━━━━━━━
Error: Usage exceeds balance (required: [usage], available: [balance])
```java

## Examples

### Example 1: Normal Point Usage (500/1000)
Input:
```java
1000
500
```java
Output:
```java
=== Point Usage Validation ===
Balance: 1000pt
Usage: 500pt
Validation: Success
━━━━━━━━━━━━━━━━
Status: Points used successfully
```java

### Example 2: Balance Exceeded Error (1000/500)
Input:
```java
500
1000
```java
Output:
```java
=== Point Usage Validation ===
Balance: 500pt
Usage: 1000pt
Validation: Failed
━━━━━━━━━━━━━━━━
Error: Usage exceeds balance (required: 1000, available: 500)
```java

### Example 3: Boundary Value (1000/1000)
Input:
```java
1000
1000
```java
Output:
```java
=== Point Usage Validation ===
Balance: 1000pt
Usage: 1000pt
Validation: Success
━━━━━━━━━━━━━━━━
Status: Points used successfully

Test Cases

※ Output examples follow programming industry standards

Input:
1000
500
Expected Output:
=== Point Usage Validation ===
Balance: 1000pt
Usage: 500pt
Validation: Success
━━━━━━━━━━━━━━━━
Status: Points used successfully
Input:
500
1000
Expected Output:
=== Point Usage Validation ===
Balance: 500pt
Usage: 1000pt
Validation: Failed
━━━━━━━━━━━━━━━━
Error: Usage exceeds balance (required: 1000, available: 500)
Input:
1000
1000
Expected Output:
=== Point Usage Validation ===
Balance: 1000pt
Usage: 1000pt
Validation: Success
━━━━━━━━━━━━━━━━
Status: Points used successfully
❌ 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