Question
In this lab, you complete the Python program that calculates the amount of tax withheld from an employees weekly salary, the tax deduction to which
In this lab, you complete the Python program that calculates the amount of tax withheld from an employees weekly salary, the tax deduction to which the employee is entitled for each dependent, and the employees take-home pay. The program output includes state tax withheld, federal tax withheld, dependent tax deductions, salary, and take-home pay. Instructions Some variables have been assigned for you and the output statements have been written. Read the starting code carefully before you proceed to the next step. Write the Python code needed to perform the following: Calculate state withholding tax (stateTax) at 6.5 percent Calculate federal withholding tax (federalTax) at 28.0 percent. Calculate dependent deductions (dependentDeduction) at 2.5 percent of the employees salary for each dependent. Calculate total withholding (totalWithholding) as stateTax + federalTax + dependentDeduction. Calculate take-home pay (takeHomePay) as salary - totalWithholding Execute the program by clicking the Run button at the bottom. You should get the following output: State Tax: $81.25 Federal Tax: $350.00000000000006 Dependents: $62.5 Salary: $1250.0 Take-Home Pay: $756.25 In this program, the variables named salary and numDependents are initialized with the values 1250.0 and 2. To make this program more flexible, modify it to accept interactive input for salary and numDependents.
my code:
# Prompt user to enter the salary
# Convert the user response to float
salary = float(input("Enter the salary amount: "))
# Prompt user to input the number of dependents
# Convert the user input to int
numDependents = int(input("Enter the number of dependents: "))
# Initialize the state tax rate
stateTaxRate = 6.5/100
# Initialize the federal tax rate
federalTaxRate = 28.0/100
# Initialize the dependent deduction rate
dependentDeductionRate = 2.5/100
# Calculate the state tax
# Multiply salary by state tax rate
stateTax = salary * stateTaxRate
# Calculate the federal tax
# Multiply salary by federal tax rate
federalTax = salary * federalTaxRate
# Calculate the dependent deduction
# Multiply salary by number of dependents and the
# dependent deduction rate
dependentDeduction = salary * numDependents * dependentDeductionRate
# Calculate the total withholding amount
# Add the state tax, federal tax and dependent deduction
totalWithholding = stateTax + federalTax + dependentDeduction
# Calculate the take home pay
# Subtract the total withholding amount from the salary
takeHomePay = salary - totalWithholding
# print a blank line
print()
# Display the output
print("State Tax: $",stateTax)
print("Federal Tax: $",federalTax)
print("Dependents: $",dependentDeduction)
print("Salary: $",salary)
print("Take-Home Pay: $ ",takeHomePay)
task:
Program produces the correct output
2
0 out of 2 checks passed. Review the results below for more details.
Checks
Test CaseIncomplete
$60,000 salary with 3 dependents
Input
60000 3
Output
Enter the salary amount: 60000 Enter the number of dependents: 3 State Tax: $ 3900.0 Federal Tax: $ 16800.0 Dependents: $ 4500.0 Salary: $ 60000.0 Take-Home Pay: $ 34800.0
Results
State Tax: $3900.0
Federal Tax: $16800.0
Dependents: $4500.0
Salary: $60000.0
Take Home Pay: $34800.0
Show DetailsTest CaseIncomplete
$30,000 salary with 6 dependents
Input
30000 6
Output
Enter the salary amount: 30000 Enter the number of dependents: 6 State Tax: $ 1950.0 Federal Tax: $ 8400.0 Dependents: $ 4500.0 Salary: $ 30000.0 Take-Home Pay: $ 15150.0
Results
State Tax: $1950.0
Federal Tax: $8400.0
Dependents: $4500.0
Salary: $30000.0
Take Home Pay: $15150.0
Show Details
Run checks
Program produces the correct output 0 out of 2 checks passed. Review the results below for more details. Enter the salary amount: 60000 Enter the number of dependents: State Tax: \$3900.0 Federal Tax: $16800.0 Dependents: $4500.0 Salary: $60000.0 Take-Home Pay: $34800.0 Output Enter the salary amount: 30000 Enter the number of dependents: State Tax: $1950.0 Federal Tax: $8400.0 Dependents: $4500.0 Salary: $30000.0 Take-Home Pay: \$15150.0 Enter the salary amount: 30000 Enter the number of dependents: State Tax: \$1950.0 Federal Tax: $8400.0 Dependents: $4500.0 Salary: $30000.0 Take-Home Pay: $15150.0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started