This lab will consist of options to users to view, add, modify or delete payroll record data
This lab will consist of options to users to view, add, modify or delete payroll record data. and doing file
processing (Payroll Program) ATTACHMENT PREVIEW Download attachmentPROJECTFile Processing –Payroll Program100 pointsObjectiveThis lab will consist of options to users to view, add, modify or deletepayroll record data. Reference to Section 6.3 of the text for niceexamples on how to handle modiFcations to a Fle.PROJECT DESCRIPTIONDownload the accompanyingemployees.txtFle from Blackboard and add it thesame program directory you have for your lab 4 python source Fle. You’ll notice theformat of Fle has layout is follows:<Frst name> <last name> <rate> <hours>where each line represents an employee’s name and payroll record data.As you can see there are a total of 4employees in the Fle with pertinent payrollrecord data.±or your programming tasks perform the following:Create menu options options from to process payroll as follows:1.A gross payroll report for all employees2.A gross payroll report for just one select employee.3.Add an employee4.Delete an employee5.Modify an employee6.Exit programCreate with a loop that will show a menu of the above options to the user where if theuser chooses:Option 1- A report of pertinent employee data will print to the screenOption 2- It will allow for the user to choose an employee by name, where ifthe nameexists in the Fle, pertinent employee data will print to the screenOption 3- Prompts the user for their name (Frst name, then a last name) followed bytheir rate of pay and hours worked and have that data addedto your payroll FleOption 4- Prompts the user for their name (Frst name, then a last name) and if arecord exists matching the employee’s Frst name and last name in the Fle, it will bedeleted.Option 5- Prompts the user for their name (Frst name, then a last name) and if arecord exists in the Fle matching the employee’s Frst name and last name, the userwill be allowed to modifyany data items (rate and/or hours) within the particularrecord.Option 6 quitsthe program. Display a nice message to the user upon the terminationof the program.Include the following processing logic in your program (make use of user deFnedfunctions that will Fre for each menu option for solid organization of your app):±or menu option 1:Use a function calledprintall(), to display all Employee data willbe displayed as follows:±irst name Last name and the gross pay, together on one line of output.© Copyright 2016 by P.E.P.Page 1 of 3

View the AnswerFor menu option 2:Use a function calledprintEmp(), to display only a singleEmployee’s data chosen by the user to be displayed as follows:First name Last name and the gross pay, on one line of output.*Note-Gross pay is calculated simply as (ratexhours) worked.-Make sure gross pay data for either option 1 or 2, is appropriately formatted(currencystyle) when displaying your report information.For menu option 3:Use a function calledaddEmp()to add (or append) record datatoyour ±leFor menu option 4:Use a function calleddeleteEmp()to delete record data fromyour ±leFor menu option 5:Use a function calledmodifyEmp()to modify record data fromyour ±leFor either menu option 6:Use a function calledexitApp()to exit of the program. Youcan evoke Python’s built in exit() function from thesysmodule, to accomplish thisNote for options 4 & 5 you will need to write to a temporary ±le each time to re²ectchanges to the original ±le. Then merely remove the temporary ±le and rename yourtemp ±le to the original ±le name to re²ect the changes.Ex. Coding logic action for option 4- record deletionimport os#needed for the removal and renaming functionsopen original ±le (employees.txt) for readingopen up a temporary ±le (ex.temp.txt) for writingstart while loop to read all record data as parsed datacheck record if a name exists and needs deleting,if the name exists don’twrite the record to the temp ±le,else writethe record that doesn’t need deleting to the temp ±leexit while loopclose out both ±les#delete original employees.txt ±leos.remove(‘employees.txt’)#rename the temporary ±leos.rename(‘temp.txt’, ‘employees.txt’)#display a message if the record was not found or if it has been found, message theuser that #the ±le has been updated!Continue in the same manner as the example code logic above for option 4 for option5 to allow for ±le modi±cation.Include anyerror traps(exceptions) you deem neceesary in your program withregards to the processing of your ±le/data. Examples may include ±le not found, orrecord not found, etc.© Copyright 2016 by P.E.P.Page 2 of 3
