An employee is paid at a rate of $16.78 per hour for the first 40 hours worked in a…
- User
An employee is paid at a rate of 10 per week is withheld for union dues. If the worker has three or more dependents, then an additional $35 is withheld to cover the extra cost of health insurance beyond what the employer pays. Write a program that will read in the number of hours worked in a week and the number of dependents as input and will then output the worker’s gross pay, each withholding amount, and the net take-home pay for the week.
- Assistant
Here is a Python program that calculates the gross pay, withholding amounts, and net take-home pay based on the provided information:
# Constants HOURLY_RATE = 16.78 OVERTIME_MULTIPLIER = 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 # Read input hours_worked = float(input("Enter the number of hours worked in a week: ")) dependents = int(input("Enter the number of dependents: ")) # Calculate gross pay if hours_worked <= 40: gross_pay = hours_worked * HOURLY_RATE else: overtime_hours = hours_worked - 40 gross_pay = (40 * HOURLY_RATE) + (overtime_hours * HOURLY_RATE * OVERTIME_MULTIPLIER) # Calculate withholding amounts 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 union_dues = UNION_DUES health_insurance = 0 if dependents < 3 else HEALTH_INSURANCE_COST # Calculate net take-home pay net_pay = gross_pay - social_security_tax - federal_income_tax - state_income_tax - union_dues - health_insurance # Output results print("Gross Pay: $", format(gross_pay, ".2f")) print("Social Security Tax: $", format(social_security_tax, ".2f")) print("Federal Income Tax: $", format(federal_income_tax, ".2f")) print("State Income Tax: $", format(state_income_tax, ".2f")) print("Union Dues: $", format(union_dues, ".2f")) print("Health Insurance: $", format(health_insurance, ".2f")) print("Net Take-Home Pay: $", format(net_pay, ".2f"))
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.