008-002-008
Object Method: Profile Display
Easy
Problem Description
Object method: Profile Display
Learning Objective: Call object method for output
In this problem, you will create a program that instantiates a Profile class object, calls its display method to format and print the name and age to standard output.
Read the name (string) and age (integer) from standard input, then pass them to the Profile class constructor to create an instance. Call the display method on the created object to output the profile in the format "Name: [name]" and "Age: [age] years old".
Input
Line 1: Name (string)
Line 2: Age (integer)
Output
Name: [name]
Age: [age] years old
```java
## Examples
### Example 1: Taro age 20
Input:
```java
Taro
20
```java
Output:
```java
Name: Taro
Age: 20 years old
```java
### Example 2: Hanako age 25
Input:
```java
Hanako
25
```java
Output:
```java
Name: Hanako
Age: 25 years old
```java
### Example 3: 1 character, age 0 (boundary)
Input:
```java
A
0
```java
Output:
```java
Name: A
Age: 0 years old
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
Alice 30
Expected Output:
Name: Alice Age: 30 years old
Normal case
Input:
Bob 18
Expected Output:
Name: Bob Age: 18 years old
Your Solution
Current Mode:● My Code
Profile.java🔒
Solution.java🔒
2/6 ファイル96B
⚠️警告
- No main method found
9
1
2
3
4
›
⌄
import java.util.Scanner;
class Profile {
}
0 B / 5 MB
You have 10 free executions remaining
