015-003-005

Downcast: Employee Class

Easy

Problem Description

Downcast: Employee class

In this problem, you will create a program that reads a name, salary, and team name from standard input, checks the type of a Manager object stored in an Employee-type variable using instanceof, downcasts it to the Manager class, and displays the employee information to standard output.

Learning Objective: Understand downcast explicitly casting parent class reference to child class type

Create an Employee class representing employees and a Manager class that inherits from it. Store a Manager object in an Employee-type variable, check its type with instanceof, cast it to the child class type (downcast), and call child-class-specific methods.

Input

Line 1: Name (string)
Line 2: Salary (integer)
Line 3: Team name (string)

Output

Employee Info:
Name: [name]
Salary: [salary]yen
Team: [team]
```java

## Examples

### Example 1: Manager Alice
Input:
```java
Alice
500000
Marketing
```java
Output:
```java
Employee Info:
Name: Alice
Salary: 500000yen
Team: Marketing
```java

### Example 2: Manager Bob
Input:
```java
Bob
600000
Sales
```java
Output:
```java
Employee Info:
Name: Bob
Salary: 600000yen
Team: Sales
```java

### Example 3: Boundary (single character values)
Input:
```java
C
1
A
```java
Output:
```java
Employee Info:
Name: C
Salary: 1yen
Team: A

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up