4. netpay = grosspay - incometax
return grosspay, incometax, netpay
def printinfo(DetailsPrinted):
TotEmployees = 0
TotHours = 0.00
TotGrossPay = 0.00
TotTax = 0.00
TotNetPay = 0.00
EmpFile = open("Employees.txt","r")
while True:
rundate = input ("Enter start date for report (MM/DD/YYYY) or All for all data in file: ")
if (rundate.upper() == "ALL"):
break
try:
rundate = datetime.strptime(rundate, "%m/%d/%Y")
break
except ValueError:
print("Invalid date format. Try again.")
print()
continue # skip next if statement and re-start loop
while True:
EmpDetail = EmpFile.readline()
if not EmpDetail:
6. EmpTotals["TotTax"] = TotTax
EmpTotals["TotNetPay"] = TotNetPay
DetailsPrinted = True
if (DetailsPrinted): #skip of no detail lines printed
PrintTotals (EmpTotals)
else:
print("No detail information to print")
def PrintTotals(EmpTotals):
print()
print(f'Total Number Of Employees: {EmpTotals["TotEmp"]}')
print(f'Total Hours Worked: {EmpTotals["TotHrs"]:,.2f}')
print(f'Total Gross Pay: {EmpTotals["TotGrossPay"]:,.2f}')
print(f'Total Income Tax: {EmpTotals["TotTax"]:,.2f}')
print(f'Total Net Pay: {EmpTotals["TotNetPay"]:,.2f}')
if __name__ == "__main__":
##################################################
########## Write the line of code to call the method CreateUsers
def function_CreateUsers():
print()
print("##### Data Entry #####")
########## Write the line of code to assign UserRole and UserName to the function Login##
def Login(GetUserRole, UserName):
DetailsPrinted = False ###
7. EmpTotals = {} ###
########## Write the if statement that will check to see if UserRole is equal to NONE (NOTE:
code will show red error lines until this line is written)####
if GetUserRole == 'NONE':
print(UserName," is invalid.")
else:
# only admin users can enter data
##### write the if statement that will check to see if the UserRole is equal to ADMIN (NOTE:
code will show red error lines until this line is written)
if GetUserRole == 'ADMIN':
EmpFile = open("Employees.txt", "a+")
while True:
empname = GetEmpName()
if (empname.upper() == "END"):
break
fromdate, todate = GetDatesWorked()
hours = GetHoursWorked()
hourlyrate = GetHourlyRate()
taxrate = GetTaxRate()
EmpDetail = fromdate + "|" + todate + "|" + empname + "|" + str(hours) + "|" + str(hourlyrate) +
"|" + str(taxrate) + "n"
EmpFile.write(EmpDetail)
# close file to save data
EmpFile.close()
printinfo(DetailsPrinted)
8. Question:
I can't get the 2nd part of the program to display. The 1st part of the program works fine. The 2ns
art of the program starts at def GetEmpName(): The second part asks for employee names,
start/end dates, hours, hourly rate, tax rate, gross pay, and net pay. Ty