001-001-001

Variable Declaration: Self-Introduction Program

Easy

Problem Description

Variable Declaration: Self-Introduction Program

Learning Objective: Understand variables as "containers" for data, and learn the basics of keyboard input and output

Create a program that displays a nice self-introduction card when you enter your name and age. Use variables to temporarily store information and use it for display.

Input

Line 1: Your name (string)
Line 2: Your age (integer)

Output

============================
   Self-Introduction Card
============================
Name: [name]
Age: [age] years old
============================
```java

## Examples

### Example 1: Taro's Introduction
Input:
```java
Taro
20
```java
Output:
```java
============================
   Self-Introduction Card
============================
Name: Taro
Age: 20 years old
============================
```java

### Example 2: Hanako's Introduction
Input:
```java
Hanako
18
```java
Output:
```java
============================
   Self-Introduction Card
============================
Name: Hanako
Age: 18 years old
============================
```java

### Example 3: Minimum Value Introduction
Input:
```java
A
0
```java
Output:
```java
============================
   Self-Introduction Card
============================
Name: A
Age: 0 years old
============================

Test Cases

※ Output examples follow programming industry standards

Input:
Taro
20
Expected Output:
============================
 Self-Introduction Card
============================
Name: Taro
Age: 20 years old
============================
Input:
Hanako
18
Expected Output:
============================
 Self-Introduction Card
============================
Name: Hanako
Age: 18 years old
============================
Input:
A
0
Expected Output:
============================
 Self-Introduction Card
============================
Name: A
Age: 0 years old
============================
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
// キーボードからのユーザー入力を読むためのScannerオブジェクトを準備
Scanner sc = new Scanner(System.in);
// 名前を入力して変数に格納
String name = sc.nextLine();
// ユーザーから年齢を入力して変数に格納
int age = sc.nextInt();
// 自己紹介カードを表示
System.out.println("============================");
// [出力処理] 結果を画面に表示
System.out.println(" Self-Introduction Card");
// [出力処理] 結果を画面に表示
System.out.println("============================");
// [出力処理] 結果を画面に表示
System.out.println("Name: " + name);
// [出力処理] 結果を画面に表示
System.out.println("Age: " + age + " years old");
// [出力処理] 結果を画面に表示
System.out.println("============================");
}
}

0 B / 5 MB

You have 10 free executions remaining