Question: I need to adjust this code to collect several employees gross pay and then calculate the total gross pay for all entered employees once the
I need to adjust this code to collect several employees gross pay and then calculate the total gross pay for all entered employees once the loop is terminated.
Here is the code I have already
employeeNum = -2 grossPay = 0.00 stateTax = 0.00 federalTax = 0.00 fica = 0.00 netPay = 0.00
while employeeNum != 0: employeeNum = int(input('Enter employee number or enter 0 to terminate loop and display results: ')) if (employeeNum == 0): break grossPay = float(input('Enter gross pay : $ ')) if grossPay < 0: grossPay = float(input('Gross pay must be greater than zero. Please re-enter: ')) stateTax = float(input('Please enter state tax : $ ')) if stateTax < 0 or stateTax > grossPay: stateTax = float(input('State tax must be greater than zero and less than gross pay. Please re-enter: ')) federalTax = float(input('Please enter federal tax : $ ')) if federalTax < 0 or federalTax > grossPay: federalTax = float(input('Federal tax must be greater than zero and less than gross pay. Please re-enter: ')) fica = float(input('Please enter FICA withholdings : $ ')) if fica < 0 or fica > grossPay: fica = float(input('FICA withholdings must be greater than zero and less than gross pay. Please re-enter: '))
netPay = grossPay - stateTax - federalTax - fica
print(' ') print('Gross pay: $', format(grossPay, '.2f')) print(' ') print('State tax: $', format(stateTax, '.2f')) print(' ') print('Federal tax: $', format(federalTax, '.2f')) print(' ') print('FICA withholdings: $', format(fica, '.2f')) print(' ') print('Net pay: $', format(netPay, '.2f')) print(' ')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
