007-002-001

Class and Object: Person Info Class

Easy

Problem Description

class and Object: Person Info class

In this problem, you will create a program that defines a Person class with a constructor to initialize name and age fields, instantiates an object from standard input, and displays the person's information to standard output.

Learning Objective: Declare class and create object

Create Person class with name and age, create object and display information. Implement constructor and methods.

Input

Line 1: Name (string)
Line 2: Age (integer)

Output

Name: [name]
Age: [age] years old

Examples

Example 1: Taro age 20

Input:

Taro
20

Output:

Name: Taro
Age: 20 years old

Example 2: Hanako age 25

Input:

Hanako
25

Output:

Name: Hanako
Age: 25 years old

Example 3: Minimum value (boundary)

Input:

A
0

Output:

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
15
Expected Output:
Name: Bob
Age: 15 years old

Your Solution

Current Mode: My Code
Person.java🔒
Solution.java🔒
2/6 ファイル126B
public class Person {
}
0 B / 5 MB

You have 10 free executions remaining