Advertisement
EricJohnson

tax_function

Apr 8th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. #ifndef _GLIBCXX_IOSTREAM
  2. #include <iostream>
  3. using namespace std;
  4. #endif
  5. //function declaration
  6. int taxes (float wage)
  7. {
  8. int search =0;
  9. float taxes =0;
  10. //lookup table for the switch input
  11. int search_table[]=
  12.         {
  13.         (wage < 500),
  14.         ((wage >= 500) && (wage < 1000)),
  15.         ((wage >= 1000) && (wage < 2000)),
  16.         (wage >= 2000)
  17.         };
  18.         //lookup table magic
  19. for(int finish =0; finish !=1; search ++)
  20.         if((search_table[search]) == 1)
  21.                 finish ++;
  22. cout << "The Federal Tax is: $" ;
  23. switch(search)
  24.         {
  25.         case (1):
  26.                 //8% tax
  27.                  taxes += wage * .08;
  28.                  cout << wage * .08 << endl;
  29.                  break;
  30.         case (2)://12% tax
  31.                  taxes += wage * .12;
  32.                  cout << wage * .12 << endl;
  33.                  break;
  34.         case (3)://15% tax
  35.                  taxes += wage * .15;
  36.                  cout << wage * .15 << endl;
  37.                  break;
  38.         case (4)://20% tax
  39.                  taxes += wage * .2;
  40.                  cout << wage * .2 << endl;
  41.                  break;
  42.         }
  43.         //1/4% tax
  44. taxes += wage * .025;
  45. cout << "The NY State Tax is: $" << wage * .025 << endl;
  46. cout << "The Social Security Tax is: $";
  47. switch(search)
  48.         {
  49.         case (1)://4% tax
  50.                  taxes += wage * .04;
  51.                  cout << wage * .04 << endl;
  52.                  break;
  53.         case (2)://6% tax
  54.                  taxes += wage * .06;
  55.                  cout << wage * .06 << endl;
  56.                  break;
  57.         case (3)://8% tax
  58.                  taxes += wage * .08;
  59.                  cout << wage *.08 << endl;
  60.                  break;
  61.         case (4)://10% tax
  62.                  taxes += wage * .1;
  63.                  cout << wage * .1 << endl;
  64.                  break;
  65.         }
  66. cout << "Your weekly net pay is: $" << wage - taxes << endl;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement