#K34117. Employee Manager Command Line Tool
Employee Manager Command Line Tool
Employee Manager Command Line Tool
This problem requires you to implement a command line tool for managing employee records in a small company. The tool supports adding a new employee, removing an existing employee by ID, and querying employees either by department or by a minimum number of years of experience. All records are stored in memory and exist only during the execution of the program.
Each employee record consists of:
- Employee ID (a unique integer)
- Name (a string)
- Department (a string)
- Years of Experience (an integer)
The program accepts the following commands (each as a separate input line):
- Add a new employee: Format:
1 emp_id name department years
. Returns "Employee added." on success or "Employee ID already exists." if the ID already exists. - Remove an employee: Format:
2 emp_id
. Returns "Employee removed." if the employee is found, otherwise "Employee does not exist." - List employees by department: Format:
3 department
. Prints each matching employee record in the formatemp_id name
on separate lines. If no employee belongs to that department, print an empty line. - List employees by years of experience: Format:
4 min_years
. Prints each employee with at least min_years years of experience in the same format as above. Print an empty line if none qualify. - Exit the program: Format:
5
. Ends the execution.
The input begins with an integer indicating the number of commands that follow. Your solution must read from standard input (stdin) and write the results to standard output (stdout).
inputFormat
The first line of input contains an integer N, the number of commands. Each of the next N lines contains a command in one of the following formats:
1 emp_id name department years
— Add a new employee.2 emp_id
— Remove an employee by ID.3 department
— List all employees in the specified department.4 min_years
— List all employees with at least the given years of experience.5
— Exit the program immediately.
Note: For commands of type 1
, assume names do not contain spaces (use underscores instead if necessary).
outputFormat
For each command (except command 5
), output the corresponding response:
- For add operation (
1
): output either "Employee added." or "Employee ID already exists.". - For remove operation (
2
): output either "Employee removed." or "Employee does not exist.". - For department query (
3
) and experience query (4
): print each matching employee record (emp_id name
) on separate lines. If no records match, output an empty line (a blank line).
All outputs must be printed to standard output (stdout) in the order the commands are processed.
## sample5
1 101 John_Doe Engineering 5
3 Engineering
4 4
2 101
5
Employee added.
101 John_Doe
101 John_Doe
Employee removed.
</p>