Exception Propagation: Point Usage Validation System
Problem Description
Exception Propagation: Point Usage Validation System
In this problem, you will create a program that reads balance points and usage points from standard input, throws IllegalArgumentException in validatePointUsage() when usage exceeds balance, propagates the exception through usePoints() to main(), and displays the result to standard output.
Learning Objective: Learn to understand how exceptions propagate through method calls
Create a point card usage validation system. When usage points exceed balance points, throw IllegalArgumentException in the validatePointUsage() method, and observe how the exception propagates through the usePoints() method up to the main() method. Without explicitly catching the exception in each intermediate method, it automatically propagates to the 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
Or when exception occurs:
=== Point Usage Validation ===
Balance: [balance]pt
Usage: [usage]pt
Validation: Failed
━━━━━━━━━━━━━━━━
Error: Usage exceeds balance (required: [usage], available: [balance])
Examples
Example 1: Normal Point Usage (500/1000)
Input:
1000
500
Output:
=== Point Usage Validation ===
Balance: 1000pt
Usage: 500pt
Validation: Success
━━━━━━━━━━━━━━━━
Status: Points used successfully
Example 2: Balance Exceeded Error (1000/500)
Input:
500
1000
Output:
=== Point Usage Validation ===
Balance: 500pt
Usage: 1000pt
Validation: Failed
━━━━━━━━━━━━━━━━
Error: Usage exceeds balance (required: 1000, available: 500)
Example 3: Boundary Value (1000/1000)
Input:
1000
1000
Output:
=== Point Usage Validation ===
Balance: 1000pt
Usage: 1000pt
Validation: Success
━━━━━━━━━━━━━━━━
Status: Points used successfully
Test Cases
※ Output examples follow programming industry standards
1000 500
=== Point Usage Validation === Balance: 1000pt Usage: 500pt Validation: Success ━━━━━━━━━━━━━━━━ Status: Points used successfully
500 1000
=== Point Usage Validation === Balance: 500pt Usage: 1000pt Validation: Failed ━━━━━━━━━━━━━━━━ Error: Usage exceeds balance (required: 1000, available: 500)
1000 1000
=== Point Usage Validation === Balance: 1000pt Usage: 1000pt Validation: Success ━━━━━━━━━━━━━━━━ Status: Points used successfully
0 100
=== Point Usage Validation === Balance: 0pt Usage: 100pt Validation: Failed ━━━━━━━━━━━━━━━━ Error: Usage exceeds balance (required: 100, available: 0)
Your Solution
You have 10 free executions remaining
