001-006-002
Variable Declaration Placement: Point Card Balance Check
Easy
Problem Description
Variable Declaration Placement: Point Card Balance Check
Learning Objective: Declare variables in appropriate locations to improve code readability
In a point card system, input member name and point balance, then display them. Declaring variables near where they are used makes programs easier to understand.
Input
Line 1: Member name (string)
Line 2: Point balance (integer)
Output
================================
Point Card Info
================================
Member: [name]
Balance: [points]pt
================================
```java
## Examples
### Example 1: Taro Tanaka, 1500pt
Input:
```java
Taro Tanaka
1500
```java
Output:
```java
================================
Point Card Info
================================
Member: Taro Tanaka
Balance: 1500pt
================================
Test Cases
※ Output examples follow programming industry standards
Input:
Taro Tanaka 1500
Expected Output:
================================ Point Card Info ================================ Member: Taro Tanaka Balance: 1500pt ================================
Input:
Hanako Sato 3200
Expected Output:
================================ Point Card Info ================================ Member: Hanako Sato Balance: 3200pt ================================
Input:
Ichiro Yamada 0
Expected Output:
================================ Point Card Info ================================ Member: Ichiro Yamada Balance: 0pt ================================
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
›
⌄
⌄
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
// キーボードからのユーザー入力を読むためのScannerオブジェクトを準備
Scanner sc = new Scanner(System.in);
// メンバー名を入力する(使用直前に宣言)
String memberName = sc.nextLine();
// ポイント残高を入力する(使用直前に宣言)
int pointBalance = sc.nextInt();
// ポイントカードの情報を表示
System.out.println("================================");
// [出力処理] 結果を画面に表示
System.out.println(" Point Card Info");
// [出力処理] 結果を画面に表示
System.out.println("================================");
// [出力処理] 結果を画面に表示
System.out.println("Member: " + memberName);
// [出力処理] 結果を画面に表示
System.out.println("Balance: " + pointBalance + "pt");
// [出力処理] 結果を画面に表示
System.out.println("================================");
}
}
0 B / 5 MB
You have 10 free executions remaining
