cents: Input hours worked and number of dependents hoursworked = float(input("Enter the…
- User
cents:
Input hours worked and number of dependents
hours_worked = float(input("Enter the number of hours worked in a week: ")) num_dependents = int(input(“Enter the number of dependents: “))
Constants for pay rates and deductions
hourly_rate = 16.78 overtime_rate = hourly_rate * 1.5 social_security_tax_rate = 0.06 federal_income_tax_rate = 0.14 state_income_tax_rate = 0.05 union_dues = 10 health_insurance_cost = 35 if num_dependents >= 3 else 0
Calculate gross pay
if hours_worked > 40: regular_hours = 40 overtime_hours = hours_worked - 40 else: regular_hours = hours_worked overtime_hours = 0
gross_pay = (regular_hours * hourly_rate) + (overtime_hours * overtime_rate)
Calculate withholdings
social_security_tax = gross_pay * social_security_tax_rate federal_income_tax = gross_pay * federal_income_tax_rate state_income_tax = gross_pay * state_income_tax_rate total_withholdings = social_security_tax + federal_income_tax + state_income_tax + union_dues + health_insurance_cost
Calculate net pay
net_pay = gross_pay - total_withholdings
Round answers to dollars and cents
gross_pay = round(gross_pay, 2) social_security_tax = round(social_security_tax, 2) federal_income_tax = round(federal_income_tax, 2) state_income_tax = round(state_income_tax, 2) total_withholdings = round(total_withholdings, 2) net_pay = round(net_pay, 2)
Output results
print(“Gross pay: $”, format(gross_pay, “.2f”), sep=””) print("Social Security tax: From this above program , Modify the payroll program that you created in the above assignment so that it allows the calculation to be repeated as often as the user wishes. Submit your code and screenshot of output.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.