Advertisement
NickG

Taxes Function - taxes.cpp

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