Question: Rewrite Program 1 using functions. The required functions are in the table below. Create a Python program that will calculate the users net pay based
Rewrite Program 1 using functions. The required functions are in the table below.
Create a Python program that will calculate the users net pay based on the tax bracket he/she is in. Your program will prompt the user for their first name, last name, their monthly gross pay, and the number of dependents.
The number of dependents will determine which tax bracket the user ends up in. The tax bracket is as follows:
- 0 1 Dependents: Tax = 20%
- 2 3 Dependents: Tax = 15%
- 4+ Dependents: Tax = 10%
After calculating the net pay, print the name of the user, the monthly gross pay, the number of dependents, the gross pay, the tax rate, and the net pay.
The formula to compute the net pay is: monthly gross pay (monthly pay * tax rate)
| function | Description |
| read_name() | Reads the name entered, and returns the name. |
| read_gross_pay() | Reads the gross pay amount, and returns the amount. |
| read_dependents() | Reads the number of dependents, and returns the number. |
| compute_tax_rate(dependents) | Computes and returns the tax rate, based on the number of dependents. |
| compute_net_pay(gross_pay, rate) | Computes and returns the net pay, based on the gross pay and the tax rate. |
| main() | Main function of the program. |
Sample run:
Enter your name: Ron Swanson Enter your gross pay: $3500 Enter number of dependents: 0
Name: Ron Swanson Gross pay: $3500.00 Dependents: 0 Tax rate: 20% Net Pay: $2800.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
