Question: Write a Python program that can be used to store records of employees. The employee details are stored in a dictionary, with the employee code

Write a Python program that can be used to store records of employees. The employee details are stored in a dictionary, with the employee code as the key, and a nested dictionary that stores the name, surname, email address, and department as value. The employee code comprises of the first 2 letters of the department name, followed by a hyphen, and a randomly generated number between 1 and 1000. The dictionary must be managed using a class. The program should have the following:
Employee record class: a class used to initialise and maintain the dictionary. The class must have the following methods:
oGenerate employee code: takes in the department and generates an employee code as specified above. Ensure that the employee code generated does not exist in the dictionary, to ensure unique keys.
(5 Marks)
oAdd employee record: takes in the name, surname, email, and department of the employee, then adds it to the dictionary. The employee code used as the key must be generated using the Generate employee code method.
(5 Marks)
oPrint employee codes: A method that prints all the employee codes generated.
(2 Marks)
oPrint employee dictionary: A method that prints all the employee records in the dictionary.
(1 Mark)
oSearch employee: Takes in the employee code and prints the details associated.
(2 Marks)
Main menu: A menu used to navigate through the program. The menu must be displayed until the program terminates.
(5 Marks)
Sample outputs: 1. Add employee record
2. Display all employee codes
3. Display all employee records
4. Search employee
5. Exit
Select a menu option: 1
Enter name:Marcel
Enter surname: Kish
Enter department: Sales
Enter email: mk@mk.mk ```
1. Add employee record
2. Display all employee codes
3. Display all employee records
4. Search employee
5. Exit
Select a menu option: 2
IT-992
SA-688
``````
Select a menu option: 3
{'IT-992': {'name': 'Marc', 'surname': 'Kish', 'department': 'IT', 'email':
'mk@mk.mk'},'SA-688': {'name': 'Marcel', 'surname': 'Kish', 'department': 'Sales',
'email': 'mk@mk.mk'}}
``` Select a menu option: 4
Enter employee code: IT-992
\{'name': 'Marc', 'surname': 'Kish', 'department': 'IT', 'email': 'mk@mk.mk'\}
Write a Python program that can be used to store

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!