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...

1 answer below »
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')
Answered 5 days AfterMar 16, 2021

Answer To: This week you will develop the fourth functionality for the Employee Management System Project due...

Pratap answered on Mar 21 2021
143 Votes
EMPLOYEE MANAGEMENT SYSTEM
Functionality 4:
Case#1: Begin with empty employee data and add two employee details to the system.
Case#2: Add one more employee details to the system
Case#3: View details of all employees present in the system
Case#4: View details of employee based on index number.
C
ase#5: View employee details based on SSN and try using non-existing SSN
Case#6: Edit the employee details in the system
Case#7: Try entering invalid option.
Variables: A dictionary of items with a key, list pairs is used to store the employee details. Dictionary key will be the integer of type string, which indicates the index of the employee in the system. The value for the key will be a list, which includes employee name, employee SSN, employee number, employee email and employee salary. The counter variable will be the length of the dictionary, which in turn tells the number of employees in the system.
Functions: Following are the function names and their functionalities –
· write_file(json_object) :- This is a generalized function used to write the dictionary of employee details(json_object) into a json file. The purpose of writing to a file is to save the added or edited data and read it when the program is restarted. This function is mentioned as generalized because writing is done during both adding and editing employee details. So this function is called twice in the program during adding and editing details.
· addEmp(i) :- This function will ask for employee details like name, SSN, number, email and salary. The parameter ‘I’ passed to the function should be the ‘count+1’, so that the new employee details will be added to the next index value. At the end after creating the appropriate dictionary object, this function will call ‘write_file(json_object)’ to write to the file, passing the employee dictionary created.
· generalView(key) :- This function is named as it is generalized function in displaying the employee details. This function is used whether the user wants to view all the employees, view employees based o index or view employees based on SSN. The parameter ‘key’ should be the key of the dictionary of which the items are to be displayed. Since lists are present in dictionary as values accessing them will be easier to display the required items in required format.
· viewAllEmployees() :- This function will collect all the keys present in the employee dictionary and passes it as parameters one by one while calling ‘generalView(key)’. Thus displaying all the employee details present in the system.
· viewEmpByIndex() :- This function will ask the user for employee SSN and calls ‘generalView(key)’ function with user entered SSN as the key parameter. Now the called function will display the employee details if the SSN matches with any of the keys, else it will throw error and the user has to try again.
· viewEmpBySSN(SSN) :- The parameter SSN is the SSN value entered by user. This function will search all the values(lists of employee details) in the...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here