In: Computer Science
Write a program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay.
Input Validation: Do not accept negative numbers for any of the items entered. Do not accept values for state, federal, or FICA withholdings that are greater than the gross pay. If the sum of state tax + federal tax + FICA withholdings for any employee is greater than gross pay, print an error message and ask the user to reenter the data for that employee.
IN PYTHON PLEASE!
Code:
while True:
employeeNumber=int(input("Enter employee number: "))
if (employeeNumber==0):
break
grossPay=float(input("Enter gross pay: "))
if (grossPay<0):
grossPay=float(input("Gross pay should be positive: "))
stateTax=float(input("Enter state tax: "))
if (stateTax<0 or stateTax>grossPay):
grossPay=float(input("State tax should be positive and less than
gross pay: "))
federalTax=float(input("Enter federal tax: "))
if (federalTax<0 or federalTax>grossPay):
federalTax=float(input("Federal tax should be positive and less
than gross pay: "))
ficaHoldings=float(input("Enter FICA holdings: "))
if (ficaHoldings<0 or ficaHoldings>grossPay):
ficaHoldings=float(input("FICA holdings should be positive and less
than gross pay: "))
netPay=grossPay-stateTax-federalTax-ficaHoldings
print("Employee Number: {}".format(employeeNumber))
print("Gross Pay: {}".format(grossPay))
print("State Tax: {}".format(stateTax))
print("Federal Tax: {}".format(federalTax))
print("Net Pay: {}".format(netPay))
Screenshot of Code:
Screenshot of Output: