019-005-001

Resource Management: Point Card Information Reading

Easy

Problem Description

Resource Management: Point Card Information Reading

Learning Objective: Learn to safely manage resources using try-with-resources statement

Create program to read point card information. Using try-with-resources statement (try (...) {}), resources like Scanner are automatically closed, preventing resource leaks. Java automatically calls close() method, eliminating programmer worry about forgetting close processing.

Example 1: Standard Card Information (ID: 12345, Owner: Tanaka, Points: 1000)

Read 3 lines of data from standard input. With try-with-resources statement, Scanner is automatically closed when exiting try block.

Input:
12345
Tanaka
1000

Output:
=== Point Card Reader ===
Card ID: 12345
Owner: Tanaka
Points: 1000pt
━━━━━━━━━━━━━━━━
Resource: Closed automatically
Status: Reading completed
```java

### Example 2: Another Card Information (ID: 67890, Owner: Suzuki, Points: 2500)
Similarly read 3 lines of data, Scanner is automatically closed. Programmer doesn't need to explicitly write resource close processing.
```java
Input:
67890
Suzuki
2500

Output:
=== Point Card Reader ===
Card ID: 67890
Owner: Suzuki
Points: 2500pt
━━━━━━━━━━━━━━━━
Resource: Closed automatically
Status: Reading completed
```java

### Example 3: Boundary Values (ID: 1, Owner: A, Points: 0)
Works correctly even with minimum card ID and 0 points boundary values. Try-with-resources statement safely manages resources with any values.
```java
Input:
1
A
0

Output:
=== Point Card Reader ===
Card ID: 1
Owner: A
Points: 0pt
━━━━━━━━━━━━━━━━
Resource: Closed automatically
Status: Reading completed
```java

## Input
Card information from standard input:
Line 1: Card ID (integer)
Line 2: Owner name
Line 3: Point balance (integer)

## Output
```java
=== Point Card Reader ===
Card ID: [ID]
Owner: [name]
Points: [points]pt
━━━━━━━━━━━━━━━━
Resource: Closed automatically
Status: Reading completed

Test Cases

※ Output examples follow programming industry standards

Input:
12345
Tanaka
1000
Expected Output:
=== Point Card Reader ===
Card ID: 12345
Owner: Tanaka
Points: 1000pt
━━━━━━━━━━━━━━━━
Resource: Closed automatically
Status: Reading completed
Input:
67890
Suzuki
2500
Expected Output:
=== Point Card Reader ===
Card ID: 67890
Owner: Suzuki
Points: 2500pt
━━━━━━━━━━━━━━━━
Resource: Closed automatically
Status: Reading completed
Input:
1
A
0
Expected Output:
=== Point Card Reader ===
Card ID: 1
Owner: A
Points: 0pt
━━━━━━━━━━━━━━━━
Resource: Closed automatically
Status: Reading completed
❌ 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