This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

taxprog finished

By: Go0dtry on Nov 28th, 2012  |  syntax: C++  |  size: 2.92 KB  |  views: 47  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2.  
  3. #include <iostream>
  4. #include <string>
  5. #include <cmath>
  6.  
  7. using namespace std;
  8.  
  9. int getChildren ();
  10.  
  11. double taxAmount(int numPeople, double salary, double pensionAmount, int standardExemption);
  12.  
  13. void getData ();
  14.  
  15. int main ()
  16.  
  17. {
  18.         getData();
  19.         return 0;
  20. }
  21.  
  22. void getData ()
  23.  
  24. {
  25.         char status = 0;
  26.         char answer = 0;
  27.         int numPeople = 0;
  28.         int numChildren = 0;
  29.         double tax = 0.0;
  30.         double salary = 0.0;
  31.         double pensionAmount = 0.0;
  32.         double deductAmount = 0.0;
  33.         double standardExemption = 0.0;
  34.  
  35.         cout<<"Enter 'm'arried or 's'ingle:";
  36.         cin>>status;
  37.         cout<<endl;
  38.  
  39.         if (status=='m'||status=='M')
  40.         {
  41.                 numChildren=getChildren();
  42.                 standardExemption=7000;
  43.  
  44.                 cout<<"Do both spouses earn an income? Enter 'Y'es or 'N'o: ";
  45.                 cin>>answer;
  46.                 cout<<endl;
  47.  
  48.                 if (answer=='y'||answer=='Y')
  49.                 {
  50.                         cout<<"Please enter combined salary: ";
  51.                         cin>>salary;
  52.                         cout<<endl;
  53.                 }
  54.                 else if (answer=='n'||answer=='N')
  55.                 {
  56.                         cout<<"Please enter your salary: ";
  57.                         cin>>salary;
  58.                         cout<<endl;
  59.                 }
  60.                 numPeople=2+numChildren;
  61.         }
  62.         else
  63.         {
  64.                 cout<<"Please enter your salary: ";
  65.                 cin>>salary;
  66.                 cout<<endl;
  67.                 standardExemption=4000;
  68.                 numPeople=1;
  69.         }
  70.  
  71.         cout<<"Please enter pension plan amount: ";
  72.         cin>>pensionAmount;
  73.         cout<<endl;
  74.  
  75.         tax = taxAmount(numPeople, salary, pensionAmount, standardExemption);
  76.         cout << "Your tax total is: " << tax << endl;
  77.         cout << "Press enter to continue..." << endl;
  78.         cin.ignore();
  79.         cin.get();
  80. }
  81.  
  82. int getChildren ()
  83.  
  84. {
  85.         int children;
  86.  
  87.         cout<<"Enter number of children under 14: ";
  88.         cin>>children;
  89.         cout<<endl;
  90.  
  91.         return children;
  92.  
  93. }
  94.  
  95. double taxAmount(int numPeople, double salary, double pensionAmount, int standardExemption)
  96. {
  97.  
  98.         double amountoftax;
  99.         double deductionPerNumPeople = (numPeople*1500.00);
  100.  
  101.         if(salary <= 15000.00)
  102.         {
  103.                 amountoftax = salary - ((deductionPerNumPeople + pensionAmount + standardExemption) * 0.15);
  104.         }
  105.         else if(salary > 15000.00 && salary <= 40000.00)
  106.         {
  107.                 amountoftax = 2250.00 + ((deductionPerNumPeople + pensionAmount + standardExemption - 15000.00) * 0.25);
  108.         }
  109.         else if(salary > 40000.00)
  110.         {
  111.                 amountoftax = 8460.00 + ((deductionPerNumPeople + pensionAmount + standardExemption - 40000.00) * 0.35);
  112.  
  113.         }
  114.  
  115.         return amountoftax;
  116. }
clone this paste RAW Paste Data