Question: I need help finishing this code I just need a few parts added in. The parts I need help with are in the # comments
I need help finishing this code I just need a few parts added in. The parts I need help with are in the # comments in the code
def GetEmpName(): empname = input("Enter employee name (END to terminate): ") return empname def GetDatesWorked(): #write the code to input fromdate and todate and return the values from the function. #Prompt the user for the dates in the following format: mm/dd/yyyy #no validations are needed for this input, we will assume the dates are entered correctly def GetHoursWorked(): hours = float(input('Enter amount of hours worked: ')) return hours def GetHourlyRate(): hourlyrate = float(input ("Enter hourly rate: ")) return hourlyrate def GetTaxRate(): taxrate = float(input ("Enter tax rate: ")) return taxrate def CalcTaxAndNetPay(hours, hourlyrate, taxrate): grosspay = hours * hourlyrate incometax = grosspay * taxrate netpay = grosspay - incometax return grosspay, incometax, netpay def printinfo(empname, hours, hourlyrate,grosspay, taxrate, incometax, netpay): print(empname, f"{hours:,.2f}", f"{hourlyrate:,.2f}", f"{grosspay:,.2f}", f"{taxrate:,.1%}", f"{incometax:,.2f}", f"{netpay:,.2f}") def printinfo(EmpDetailList): TotEmployees = 0 TotHours = 0.00 TotGrossPay = 0.00 TotTax = 0.00 TotNetPay = 0.00 for EmpList in EmpDetailList: fromdate = EmpList[0] #write code to assign values to todate, empname, hours, hourlyrate, and taxrate from EmpLst grosspay, incometax, netpay = CalcTaxAndNetPay(hours, hourlyrate, taxrate) print(fromdate, todate, empname, f"{hours:,.2f}", f"{hourlyrate:,.2f}", f"{grosspay:,.2f}", f"{taxrate:,.1%}", f"{incometax:,.2f}", f"{netpay:,.2f}") TotEmployees += 1 TotHours += hours TotGrossPay += grosspay TotTax += incometax TotNetPay += netpay EmpTotals["TotEmp"] = TotEmployees # write code to assign TotHours, TotGrossPay, TotTax, and TotNetPay to corresponding dictionary item def PrintTotals(TotEmployees, TotHours, TotGrossPay, TotTax, TotNetPay): print()n print(f"Total Number Of Employees: {TotEmployees}") print(f"Total Hours Worked: {TotHours:,.2f}") print(f"Total Gross Pay: {TotGrossPay:,.2f}") print(f"Total Income Tax: {TotTax:,.2f}") print(f"Total Net Pay: {TotNetPay:,.2f}") def PrintTotals(EmpTotals): print() # use dictionary to print totals # the following line of code prints Total Employees from the dictionary print(f'Total Number Of Employees: {EmpTotals["TotEmp"]}') # write code to print TotalHrs, TotGrossPay, TotTax and TotNetPay from dictionary if __name__ == "__main__": # COMMENT OUT THE FOLLOWING CODE TotEmployees = 0 TotHours = 0.00 TotGrossPay = 0.00 TotTax = 0.00 TotNetPay = 0.00 EmpDetailList = [] EmpTotals = {} while True: empname = GetEmpName() if (empname.upper() == "END"): break fromdate, todate = GetDatesWorked() hours = GetHoursWorked() hourlyrate = GetHourlyRate() taxrate = GetTaxRate() grosspay, incometax, netpay = CalcTaxAndNetPay(hours, hourlyrate, taxrate) printinfo(empname, hours, hourlyrate, grosspay, taxrate, incometax, netpay) #write code to insert fromdate, todate, empname, hours, hourlyrate, and taxrate into list EmpDetail #the following code appends the list EmpDetail to the list EmpDetailList EmpDetailList.append(EmpDetail) TotEmployees += 1 TotHours += hours TotGrossPay += grosspay TotTax += incometax TotNetPay += netpay printinfo(EmpDetailList) PrintTotals (EmpTotals)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
