Please see attachment
This week you will develop the fourth functionality for the Employee Management System Project due in Week 5. Continue to use variables, functions, and control structures to improve the “View all Employees” functionality you developed in Week 3 and utilize functions and the passing of parameters to add two new functionalities to your Employee Management System. Update the “View all Employees” functionality you have developed in Week 3 to view the result in the following format: ---------------------------- Mike Smith ----------------------------- SSN: 123123123 Phone: 111-222-3333 Email: mike@g'mail.com Salary: $6000 ------------------------------------------------------------------------ ---------------------------- Sara Smith ----------------------------- SSN: 123123111 Phone: 111-222-4444 Email:
[email protected] Salary: $6500 ------------------------------------------------------------------------ Now you will continue to employ the list data structure and utilize functions to add the following two new functions: · Search employee by SSN: This functionality makes use of looping and string parsing to search all the employees in the list and returns the information of the employee who has a SSN similar to the one that the user provided. Your system should display the employee information in the following format: ---------------------------- Mike Smith ----------------------------- SSN: 123123123 Phone: 111-222-3333 Email:
[email protected] Salary: $6000 ------------------------------------------------------------------------ · Edit employee information: This functionality makes use of the “Search employee by SSN” function first to find the right employee, then it will allow the user to edit the information of the selected user. Once completed Functionality 4, you must provide the following in a Word document: · One screen shot of each completed functionality. · An explanation of how variables, functions, and control structures were used to improve the “View all Employees” functionality to view results in the format provided. · An explanation of how you employed the list data structure to add the two new functions, “Search employee by SSN” and “Edit employee information.” · A brief description of the purpose of this functionality. Paragraph format · The script The Employee Management System – Functionality 4 paper · Must include a screen shot of Functionality 4. · Must include an attached zip folder that contains a running source code for Functionality 4. · Must include a separate title page with the following: · Title of paper · Student’s name · Course name and number · Instructor’s name · Date submitted Week 1 Assignment Employee Management System Functionality 3 Melaine Weaver The University of Arizona Global Campus CPT200: Fundamentals of Programming Languages Dr. Amjad Alkilani March 22, 2021 Variables Used in Program employeeName = This variable is used to store in employee name employeeSSN = This variable is used to store in employee SSN employeeNumber = This variable is used to store in employee number employeeEmail = This variable is used to store in employee email employeeSalary = This variable is used to store in employee salary phoneNumber = This variable is used to store phone number in proper format counter = This variable is keeping a track of the number of employees emp_dict = This variable is used to create the dictionary for storing employee’s information using index While loop is used in this score for executing the 2 functionalities declared in the program. The while loop will allow us to select any option for either adding the information of employee or to view the information of existing employees. Then loop will continue until the user selects the option to exit from the code. The loop will allow user to add information or view information again and again. Earlier we were using while loop and the code was written under it for adding information or to view the information of employees. In this code we have created 2 different programs. The program will start with a while loop. It will ask the user to enter option. If user enters one, then program will call add employee function. If user enters to then the program will call view employee function. If user enters zero, then loop will break, and program will stop. If user enters any other value, then it will show a message of invalid choice and loop will continue. The ad employee method will allow the user to enter information about the employees and it will be added to the dictionary. View employee method will ask user to enter the index value of an employee and then it will print information about that employee. The methods are created to make it easier for the developer to make changes in code again and again. With the help of methods, the code becomes more reliable, and it becomes adaptable for the changes. I have declared counter variable as the global variable which will keep track of the number of employees. The value of counter is initially declared as 3 because we have already inserted information about 3 employees in the dictionary. If the user selects add employee method and adds information about the employee, then this counter value will increase by one and it will be printed in the code. import re counter=2 emp_dict = { 1: "Mark, 123M, (111)222-3333,
[email protected], $60000", 2: "Jones, J122, (222)333-4444,
[email protected], $5000" } def AddEmp(i): print("-----Employee ",counter,"-----") employeeName = input("Enter name: ") employeeSSN = input("Enter SSN: ") employeeNumber = int(input("Enter phone number: ")) phoneNumber = re.sub(r'(\d{3})(\d{3})(\d{4})', r'(\1)\2-\3', str(employeeNumber)) employeeEmail = input("Enter email: ") employeeSalary = float(input("Enter salary: ")) print('---------------------------------------------') info = employeeName+', '+employeeSSN+', '+str(phoneNumber)+', '+employeeEmail+', $'+str(employeeSalary) emp_dict[counter] = info def ViewEmp(): userInput = int(input("Please enter index value to view employee's information: ")) print(emp_dict[userInput]) while(True): print(f'There are {counter} employees in the system') print('1. Add information about employee') print('2. View information about employee') print('0 to exit') choice = int(input('Select one of the options: a')) if (choice == 0): break elif (choice == 1): counter = counter+1 AddEmp(counter) elif (choice == 2): ViewEmp() else: print('Invalid choice')