Employee Management System Python Phase 3 Please check Test Cases before posting your answer 1. Add ability to backup an
Posted: Mon Jun 06, 2022 4:43 pm
Employee Management System Python Phase
3
Please check Test Cases before posting your
answer
1. Add ability to backup and restore the database (option 7 and
8)
a. These new options for backing up and restoring the database
will work with CSV files. Option 7 will back up the database to a
CSV file with a given name and option 8 will restore the database
from a given CSV file.
b. While entering the filename for backup or restore, the user
should have an option of entering "QUIT" (case-insensitive), after
which the program should return to the main menu.
c. During database backup employee records from the database can
be written to the CSV file in any order.
d. During database restore, the database will be cleared before
restoring all employee records from the CSV file.
e. After a successful backup, the program should print
"Successfully backed up the database to CSV file
<filename.csv>." (filename.csv should be replaced with the
actual filename given)
f. If the database backup fails, then the program should print
"Unable to back up the database to CSV file <filename.csv>."
(filename.csv should be replaced with the actual filename
given)
g. After a successful restore, the program should print
"Successfully restored the database from CSV file
<filename.csv>." (filename.csv should be replaced with the
actual filename given)
h. If the database restore fails, then the program should print
"Unable to restore the database from CSV file
<filename.csv>." (filename.csv should be replaced with the
actual filename given)
2. Add more information to Display Statistics option (option
5)
a. Statistics for each department should include the maximum,
minimum, and average salary for that department. The same should be
calculated and displayed for the entire company.
Hints for implementing statistics:
Just like in Phase 2, create a temporary dictionary for keeping
track of department statistics. The main difference now is that the
values in this temporary dictionary will be small dictionaries with
for key/value entries:
- key "count" will hold a value equal to the number of employees
in a given department
- key "sum_salary" will hold the sum of all salaries in a given
department
- key "max_salary" will hold the maximum value of all salaries
in a given department
- key "min_salary" will hold the minimum value of all salaries
in a given department
Scan all employees one by one. For each employee get the
department name. Check the temporary dictionary. If the department
is there, then update that entry. Add the necessary logic for
calculating the sum/max/min values of salaries. If the department
is not there, then create a new entry where the key equals the
department name and value is a new dictionary with four entries as
described above. At the end of this process, when all employees are
processed, you'll have a dictionary with all departments and their
respective statistics. Average salary can be calculated by dividing
the sum of all salaries by the count of employees
Test Case 1
Welcome to Employee Management System (EMS)\n
Unable to load the database from binary file employee.dat.\n
Creating an empty database.\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
10ENTER
Thank you for using Employee Management System (EMS)\n
Test Case 2
Welcome to Employee Management System (EMS)\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
6ENTER
Employee database is empty.\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
10ENTER
Thank you for using Employee Management System (EMS)\n
Test Case 3
Welcome to Employee Management System (EMS)\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
111ENTER
Enter employee name:\n
Michael JordanENTER
Enter employee department:\n
EngineeringENTER
Enter employee title:\n
Software EngineerENTER
Enter employee salary:\n
65000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
112ENTER
Enter employee name:\n
Michael JacksonENTER
Enter employee department:\n
QAENTER
Enter employee title:\n
QA AnalystENTER
Enter employee salary:\n
35000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
113ENTER
Enter employee name:\n
Michael JonesENTER
Enter employee department:\n
EngineeringENTER
Enter employee title:\n
Sr. Software EngineerENTER
Enter employee salary:\n
75000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
114ENTER
Enter employee name:\n
Michael WilliamsENTER
Enter employee department:\n
QAENTER
Enter employee title:\n
Sr. QA AnalystENTER
Enter employee salary:\n
45000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
115ENTER
Enter employee name:\n
Michael JohnsonENTER
Enter employee department:\n
EngineeringENTER
Enter employee title:\n
Engineering ManagerENTER
Enter employee salary:\n
91000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
116ENTER
Enter employee name:\n
Michael SmithENTER
Enter employee department:\n
QAENTER
Enter employee title:\n
QA ManagerENTER
Enter employee salary:\n
64000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
5ENTER
Department Statistics:\n
\tDepartment: Engineering - 3 employees\n
\t\tMaximum Salary: $ 91,000.00\n
\t\tMinimum Salary: $ 65,000.00\n
\t\tAverage Salary: $ 77,000.00\n
\tDepartment: QA - 3 employees\n
\t\tMaximum Salary: $ 64,000.00\n
\t\tMinimum Salary: $ 35,000.00\n
\t\tAverage Salary: $ 48,000.00\n
There are 2 departments in the database.\n
There are 6 employees in the database.\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
6ENTER
Employee ID: 111\n
\tName: Michael Jordan\n
\tDepartment: Engineering\n
\tTitle: Software Engineer\n
\tSalary: 65,000.00\n
Employee ID: 112\n
\tName: Michael Jackson\n
\tDepartment: QA\n
\tTitle: QA Analyst\n
\tSalary: 35,000.00\n
Employee ID: 113\n
\tName: Michael Jones\n
\tDepartment: Engineering\n
\tTitle: Sr. Software Engineer\n
\tSalary: 75,000.00\n
Employee ID: 114\n
\tName: Michael Williams\n
\tDepartment: QA\n
\tTitle: Sr. QA Analyst\n
\tSalary: 45,000.00\n
Employee ID: 115\n
\tName: Michael Johnson\n
\tDepartment: Engineering\n
\tTitle: Engineering Manager\n
\tSalary: 91,000.00\n
Employee ID: 116\n
\tName: Michael Smith\n
\tDepartment: QA\n
\tTitle: QA Manager\n
\tSalary: 64,000.00\n
There are 6 employees in the database.\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
10ENTER
Thank you for using Employee Management System (EMS)\n
3
Please check Test Cases before posting your
answer
1. Add ability to backup and restore the database (option 7 and
8)
a. These new options for backing up and restoring the database
will work with CSV files. Option 7 will back up the database to a
CSV file with a given name and option 8 will restore the database
from a given CSV file.
b. While entering the filename for backup or restore, the user
should have an option of entering "QUIT" (case-insensitive), after
which the program should return to the main menu.
c. During database backup employee records from the database can
be written to the CSV file in any order.
d. During database restore, the database will be cleared before
restoring all employee records from the CSV file.
e. After a successful backup, the program should print
"Successfully backed up the database to CSV file
<filename.csv>." (filename.csv should be replaced with the
actual filename given)
f. If the database backup fails, then the program should print
"Unable to back up the database to CSV file <filename.csv>."
(filename.csv should be replaced with the actual filename
given)
g. After a successful restore, the program should print
"Successfully restored the database from CSV file
<filename.csv>." (filename.csv should be replaced with the
actual filename given)
h. If the database restore fails, then the program should print
"Unable to restore the database from CSV file
<filename.csv>." (filename.csv should be replaced with the
actual filename given)
2. Add more information to Display Statistics option (option
5)
a. Statistics for each department should include the maximum,
minimum, and average salary for that department. The same should be
calculated and displayed for the entire company.
Hints for implementing statistics:
Just like in Phase 2, create a temporary dictionary for keeping
track of department statistics. The main difference now is that the
values in this temporary dictionary will be small dictionaries with
for key/value entries:
- key "count" will hold a value equal to the number of employees
in a given department
- key "sum_salary" will hold the sum of all salaries in a given
department
- key "max_salary" will hold the maximum value of all salaries
in a given department
- key "min_salary" will hold the minimum value of all salaries
in a given department
Scan all employees one by one. For each employee get the
department name. Check the temporary dictionary. If the department
is there, then update that entry. Add the necessary logic for
calculating the sum/max/min values of salaries. If the department
is not there, then create a new entry where the key equals the
department name and value is a new dictionary with four entries as
described above. At the end of this process, when all employees are
processed, you'll have a dictionary with all departments and their
respective statistics. Average salary can be calculated by dividing
the sum of all salaries by the count of employees
Test Case 1
Welcome to Employee Management System (EMS)\n
Unable to load the database from binary file employee.dat.\n
Creating an empty database.\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
10ENTER
Thank you for using Employee Management System (EMS)\n
Test Case 2
Welcome to Employee Management System (EMS)\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
6ENTER
Employee database is empty.\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
10ENTER
Thank you for using Employee Management System (EMS)\n
Test Case 3
Welcome to Employee Management System (EMS)\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
111ENTER
Enter employee name:\n
Michael JordanENTER
Enter employee department:\n
EngineeringENTER
Enter employee title:\n
Software EngineerENTER
Enter employee salary:\n
65000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
112ENTER
Enter employee name:\n
Michael JacksonENTER
Enter employee department:\n
QAENTER
Enter employee title:\n
QA AnalystENTER
Enter employee salary:\n
35000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
113ENTER
Enter employee name:\n
Michael JonesENTER
Enter employee department:\n
EngineeringENTER
Enter employee title:\n
Sr. Software EngineerENTER
Enter employee salary:\n
75000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
114ENTER
Enter employee name:\n
Michael WilliamsENTER
Enter employee department:\n
QAENTER
Enter employee title:\n
Sr. QA AnalystENTER
Enter employee salary:\n
45000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
115ENTER
Enter employee name:\n
Michael JohnsonENTER
Enter employee department:\n
EngineeringENTER
Enter employee title:\n
Engineering ManagerENTER
Enter employee salary:\n
91000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
1ENTER
Enter an Employee ID or QUIT to stop:\n
116ENTER
Enter employee name:\n
Michael SmithENTER
Enter employee department:\n
QAENTER
Enter employee title:\n
QA ManagerENTER
Enter employee salary:\n
64000.00ENTER
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
5ENTER
Department Statistics:\n
\tDepartment: Engineering - 3 employees\n
\t\tMaximum Salary: $ 91,000.00\n
\t\tMinimum Salary: $ 65,000.00\n
\t\tAverage Salary: $ 77,000.00\n
\tDepartment: QA - 3 employees\n
\t\tMaximum Salary: $ 64,000.00\n
\t\tMinimum Salary: $ 35,000.00\n
\t\tAverage Salary: $ 48,000.00\n
There are 2 departments in the database.\n
There are 6 employees in the database.\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
6ENTER
Employee ID: 111\n
\tName: Michael Jordan\n
\tDepartment: Engineering\n
\tTitle: Software Engineer\n
\tSalary: 65,000.00\n
Employee ID: 112\n
\tName: Michael Jackson\n
\tDepartment: QA\n
\tTitle: QA Analyst\n
\tSalary: 35,000.00\n
Employee ID: 113\n
\tName: Michael Jones\n
\tDepartment: Engineering\n
\tTitle: Sr. Software Engineer\n
\tSalary: 75,000.00\n
Employee ID: 114\n
\tName: Michael Williams\n
\tDepartment: QA\n
\tTitle: Sr. QA Analyst\n
\tSalary: 45,000.00\n
Employee ID: 115\n
\tName: Michael Johnson\n
\tDepartment: Engineering\n
\tTitle: Engineering Manager\n
\tSalary: 91,000.00\n
Employee ID: 116\n
\tName: Michael Smith\n
\tDepartment: QA\n
\tTitle: QA Manager\n
\tSalary: 64,000.00\n
There are 6 employees in the database.\n
Main Menu:\n
1.\tAdd Employee\n
2.\tFind Employee by EID\n
3.\tFind Employee by Name\n
4.\tDelete Employee\n
5.\tDisplay Statistics\n
6.\tDisplay All Employees\n
7.\tBackup Database\n
8.\tRestore Database\n
9.\tPurge Database\n
10.\tExit\n
Enter your selection (1..10):\n
10ENTER
Thank you for using Employee Management System (EMS)\n