logo

UTK Notes


Lab 04: Take Home Pay Calculator

Assignment

You will be creating a program that allows the user to enter in an annual job salary. Your program will then output information about taxes, your post-tax salary, and your monthly take-home pay. (Note: if using this later in life, it will not take into account state income taxes or potential deductions you might receive).

How Income Tax Works

Listed below is the 2022 Income Tax Brackets. Let’s say you have a job offer for $70,000 / year. This falls into the 22% bracket, but your entire income is NOT taxed at 22%, only your money from $41,776 and above (i.e. $70,000 - $41,775 = $28,225). Just $28,225 of your salary is taxed at 22%. Then $31,500 (($41,775 - $10,275) is taxed at 12% and the rest is taxed at 10%.

Watch the following YouTube video for an explanation (note, uses 2020 brackets): youtube.com/watch?v=SJL4UT4wAxc


Social Security tax and Medicare tax are calculated differently and are simple:

Social Security Tax Rate * Annual Salary = Social Security Tax

Medicare Tax Rate * Annual Salary = Medicare Tax

Tax Rates

The following are the 2022 Tax Brackets for a single filer:

1
2
3
4
5
6
7
10%                Up to $10,275
12%                $10,276 - $41,775
22%                $41,776 - $89,075
24%                $89,076 - $170,050
32%                $170,051 - $215,950
35%                $215,951 - $539,900
37%                $539,901 and over

Social security tax is 6.2% of gross wages (annual salary).

Medicare tax is 1.45% of gross wages (annual salary).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Enter a salary: $70500
-----------------------------------
Yearly Salary:           $ 70500.00
Social Security Tax:     $  4371.00
Medicare Tax:            $  1022.25
Income Tax:              $ 11127.00
-----------------------------------
Take Home Salary:        $ 53979.75
Monthly Take Home Pay:   $  4498.31



Enter a salary: $5000
This is less than minimum wage for a yearly salary.



Enter a salary: $751500
-----------------------------------
Yearly Salary:           $751500.00
Social Security Tax:     $ 46593.00
Medicare Tax:            $ 10896.75
Income Tax:              $241010.00
-----------------------------------
Take Home Salary:        $453000.25
Monthly Take Home Pay:   $ 37750.02



Enter a salary: $2500100
-----------------------------------
Yearly Salary:           $2500100.00
Social Security Tax:     $155006.20
Medicare Tax:            $ 36251.45
Income Tax:              $887992.00
-----------------------------------
Take Home Salary:        $1420850.35
Monthly Take Home Pay:   $118404.20



Enter a salary: $300160
-----------------------------------
Yearly Salary:           $300160.00
Social Security Tax:     $ 18609.92
Medicare Tax:            $  4352.32
Income Tax:              $ 78809.00
-----------------------------------
Take Home Salary:        $198388.76
Monthly Take Home Pay:   $ 16532.40



Enter a salary: $13800
This is less than minimum wage for a yearly salary.



Enter a salary: $25000
-----------------------------------
Yearly Salary:           $ 25000.00
Social Security Tax:     $  1550.00
Medicare Tax:            $   362.50
Income Tax:              $  2794.50
-----------------------------------
Take Home Salary:        $ 20293.00
Monthly Take Home Pay:   $  1691.08

Restrictions

  1. You must use i/o manipulators from the <iomanip> library. You cannot use printf.
  2. You must print an error message if the salary is less than minimum wage for a yearly salary ($15080) and exit the program if you fall into this case.
  3. You must match the output EXACTLY:
    • All numerical values are printed to 2 decimal places.
    • The output consists of
      • 1 line of 35 dashes
      • Yearly Salary, Social Security Tax, Medicare Tax, and Income Tax on 4 separate lines as Label: $Value
      • 1 line of 35 dashes
      • Take Home Salary, Take Home Monthly Pay on 2 separate lines as Label: $Value
      • The labels must be set to a field width of 25 and left justified. The values must be set to a field width of 9 and right justified.
  4. Comments and good formatting are required.

Submission

Your code must compile and run on the Tesla machines, or it will not be graded! Submit your file as TakeHomePay.cpp.