Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a python 2.7 program that reads the following information and prints a pay

ID: 3872458 • Letter: W

Question

Write a python 2.7 program that reads the following information and prints a payroll statement:

"Employee’s name

Number of hours worked in a week

Hourly pay rate

State tax withholding rate

Federal Withholding

If the gross pay is less than $100.00, set the rate at 0%.

If it's at least $100.00 but less than $200.00, set the rate at 5%.

If it's at least $200.00 but less than $300.00, set the rate at 10%.

If it's at least $300.00 but less than $400.00, set the rate at 15%.

Else, if it's $400.00 or more, set the rate at 20%."





A sample run is shown below:

Enter employee's name: Smith

Enter number of hours worked in a week: 10

Enter hourly pay rate: 10.75

Enter state tax withholding rate: .09

Employee Name: Smith

Hours Worked: 10.0

Pay Rate: $10.75

Gross Pay: $107.5

Deductions:

    Federal Withholding (5.0%): 5.38

    State Withholding (9.0%): 9.67

    Total Deduction: $15.05

Net Pay: $92.45

Enter employee's name: Taylor

Enter number of hours worked in a week: 40

Enter hourly pay rate: 13.00

Enter state tax withholding rate: .15

Employee Name: Taylor

Hours Worked: 40.0

Pay Rate: $13.0

Gross Pay: $520.0

Deductions:

    Federal Withholding (20.0%): 104.0

    State Withholding (15.0%): 78.0

    Total Deduction: $182.0

Net Pay: $338.0

Notes:

You will need to use floating point numbers.  During user input think about what was used for integer input.

For decimal rounding look up the round function

Explanation / Answer

#Python 2.7

nameVar = raw_input("Enter Employee's Name: ") # input from user
hrsInWeekInt = int(raw_input("Enter number of hours worked in a week:
")) # input from user and converting it into integer
hrRateFloat = float(raw_input("Enter hourly rate: ")) # input from
user and converting it into float
stateTaxRateFloat = float(raw_input("Enter State tax withholing rate:
")) # input from user and converting it into float
print "Employee Name: ",nameVar,
print "Hours Worked: ",hrsInWeekInt
print "Pay Rate: $",hrRateFloat
print "Gross Pay: $",(hrsInWeekInt*hrRateFloat)
totalPay = float(hrsInWeekInt*

hrRateFloat)
print "Deductions:"
if totalPay < 100: #nested if else for checking federal rate
federalRate = 0
elif totalPay>=100 and totalPay<200: #nested if else for checking
federal rate
federalRate = 5
elif totalPay>=200 and totalPay<300: #nested if else for checking
federal rate
federalRate = 10
elif totalPay>=300 and totalPay<400: #nested if else for checking
federal rate
federalRate = 15
elif totalPay>=400: #nested if else for checking
federal rate
federalRate = 20
federalTax = float(federalRate*totalPay/100) # calculating federal tax
stateTax = float(stateTaxRateFloat*totalPay) # calculating State tax
print " Federal Withholding(",federalRate,"%):",federalTax
print " State Withholding(",stateTaxRateFloat,"%):",stateTax
print " Total Deduction: $",federalTax+stateTax
print " NetPay: $",totalPay-federalTax-stateTax

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote