Advertisement
BojidarDosev

American income tax calculator/ Enter relationship status( married or not) and your income,

Nov 22nd, 2023
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void tax(string answer, int inc)
  6. {
  7.     double tax = 0;
  8.     if (answer == "Yes" || answer == "yes")
  9.     {
  10.         //single
  11.         if (inc > 0 && inc <= 21400)
  12.         {
  13.             tax = inc * 0.15;
  14.             cout << tax;
  15.         }
  16.         else if (inc >21450 && inc <= 51900)
  17.         {
  18.             tax = 3217.50 + (inc- 21450.00) * 0.28;
  19.             cout << tax;
  20.         }
  21.         else if (inc > 51900)
  22.         {
  23.             tax = 11743.00 + (inc - 51900.00) * 0.31;
  24.             cout << tax;
  25.         }
  26.         else
  27.         {
  28.             cout << "Incorrect income value. Try again.";
  29.         }
  30.     }
  31.     else if (answer == "No" || answer == "no")
  32.     {
  33.         //married
  34.         if (inc > 0 && inc <= 35800)
  35.         {
  36.             tax = inc * 0.15;
  37.             cout << tax;
  38.         }
  39.         else if (inc > 35800 && inc <= 86500)
  40.         {
  41.             tax = 5370.00 + (inc - 35800.00) * 0.28;
  42.             cout << tax;
  43.         }
  44.         else if (inc > 86500)
  45.         {
  46.             tax = 19566.00 + (inc - 86500.00) * 0.31;
  47.             cout << tax;
  48.         }
  49.         else
  50.         {
  51.             cout << "Incorrect income value. Try again.";
  52.         }
  53.     }
  54.     else
  55.     {
  56.         cout << "Incorrect relationship status. Try again.";
  57.     }
  58. }
  59.  
  60. int main()
  61. {
  62.     string answer;
  63.     int inc;
  64.     cout << "Are you single? \n";
  65.     cin >> answer;
  66.     cout << "What is your income? \n";
  67.     cin >> inc;
  68.     cout << "Your tax is: $";
  69.     tax(answer, inc);
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement