Question: Please write this program in Python Code Specifications: This assignment requires user defined functions described below. No global variables are accepted. A while loop should
Please write this program in Python
Code Specifications:
This assignment requires user defined functions described below.
No global variables are accepted.
A while loop should be used to read the data sets from the file. Do not use a for loop variant. Infinite while True: loops with any jump statements such as break or continue are not accepted.
Include the following functions. Do not change the function headings or purpose. Include the function comment.
Include the main function at the top of the code def main :
This function is passed the hours and the rate and returns the regular pay based on hourly rate def regularpay hours rate: # return amount of regular pay
This function is passed the hours and the rate and returns the overtime pay based on overtime rate def overtime pay hours rate: # return amount of overtime pay
This function is passed the gross pay and the number of dependents and returns the federal tax. def federaltax gross dependents: # return amount of federal tax
This function is passed the gross pay and and returns the state tax. def statetax gross: # return amount of state tax do not use While true loops, break or jump. Use only While loop.
Notes:
Use the same documentation and design rules as stated in previous assignments.
This problem studies use of functions, exceptions and reading data from an input file to produce a payroll report. Input text file payroll.txt contains an unknown number of data sets. Each data set lists an employee identification number, name, integer number of dependents, integer hours worked and hourly pay rate with one entry per line. Text file payrolltxt contains another sample.
Ask the user for the name of the input text file using a try except statement. If the file cannot be found, the except suite should report an error message and end the program.
Read, process, and display each line of data. The code should be able to handle any number of data sets so it works for any input file. Assume the file contains at least one data set. Assume data is valid. This code should use a while loop.
Product a report similar to the one below with respect to layout. Regular pay uses the hourly rate up to hours. Overtime pay is pay for hours over at times the hourly rate. Gross pay is the sum of regular pay and overtime pay. Federal tax is gross pay dependents State tax is of gross pay. Net pay is gross pay minus taxes. The report should make columns with strings and use decimals on monetary amounts. Display the number of employees awarded overtime and the sum of overtime pay at the bottom of the report.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
