Write a program that requests the hours worked in a week the
Write a program that requests the hours worked in a week then outputs the gross pay, taxes, and net pay. Assume the following: Base pay rate = $16.00 per hour. Overtime (in excess of 40 hours) = time and a half. Tax rate = 20% of the first $300, 22% of the next $150, and 25% of the rest. Test your program thoroughly and turn in output for a person who worked 57 hours. Make sure your output looks like currency (dollar signs and two decimal places).
Solution
import os
import sys
hours = raw_input(\"No. of hours: \")
hours = int(hours)
def tax(base_pay):
if base_pay < 300:
taxes = float(base_pay*20/100)
print \"Taxes:$\"+str(taxes)
if base_pay > 300 and base_pay < 450:
tax1 = float(300*20/100)
rem = base_pay-300
tax2 = float(rem*22/100)
taxes = float(tax1 + tax2)
print \"Taxes:$\"+str(taxes)
if base_pay > 450:
tax1 = float(300*20/100)
tax2 = float(150*22/100)
rem = base_pay-450
tax3 = float(rem*25/100)
taxes = float(tax1+tax2+tax3)
print \"Taxes:$\"+str(taxes)
print \"Net Pay:$\"+str(float(base_pay-taxes))
return
if hours < 40:
base_pay = float(hours*16)
print \"Gross pay:$\"+str(base_pay)
tax(base_pay)
else:
base_pay = float(40*16)
extra_hours = hours - 40
base_pay = base_pay + float((extra_hours)*24)
print \"Gross pay:$\"+str(base_pay)
tax(base_pay)
