015-004-007
Type-based Filtering with ArrayList
Hard
Problem Description
Type-based Filtering with ArrayList
In this problem, you will create a program that defines an Employee class with subclasses Manager and Developer, reads employee data from standard input into an ArrayList<Employee>, then uses the instanceof operator to filter and count only Developer elements, and displays the result to standard output.
Learning Objective: Understand how to filter elements in ArrayList by type using instanceof
Overview
Create a program that extracts and counts only specific child class elements from a parent class type ArrayList.
Specifications
- Define Employee class and its subclasses Manager, Developer
- Read the number of employees and each employee's data from standard input
- Add employees to ArrayList
- Count Developers using instanceof
Input Format
N
type1 name1
type2 name2
...
N: number of employees (integer)type: employee type (M=Manager,D=Developer)name: employee name
Output Format
Total employees: N
Developers: D
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