Advertisement
Go0dtry

tax program

Nov 28th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int getChildren ();
  8.  
  9. double taxAmount(int, double, double, int);
  10.  
  11. void getData ();
  12.  
  13. int main ()
  14.  
  15. {
  16.         getData();
  17.         return double;
  18. }
  19.  
  20. void getData ()
  21.  
  22. {
  23.         char status, answer;
  24.         int numChildren;
  25.         double salary, pensionAmount, deductAmount;
  26.         int numPeople, standardExemption;
  27.         double tax;
  28.  
  29.         cout<<"Enter 'm'arried or 's'ingle:";
  30.         cin>>status;
  31.         cout<<endl;
  32.  
  33.         if (status=='m'||status=='M')
  34.         {
  35.                 numChildren=getChildren();
  36.                 standardExemption=7000;
  37.  
  38.                 cout<<"Do both spouses earn an income? Enter 'Y'es or 'N'o: ";
  39.                 cin>>answer;
  40.                 cout<<endl;
  41.  
  42.                 if (answer=='y'||answer=='Y')
  43.                 {
  44.                         cout<<"Please enter combined salary: ";
  45.                         cin>>salary;
  46.                         cout<<endl;
  47.                 }
  48.                 else if (answer=='n'||answer=='N')
  49.                 {
  50.                         cout<<"Please enter your salary: ";
  51.                         cin>>salary;
  52.                         cout<<endl;
  53.                 }
  54.                 numPeople=2+numChildren;
  55.         }
  56.         else
  57.         {
  58.                 cout<<"Please enter your salary: ";
  59.                 cin>>salary;
  60.                 cout<<endl;
  61.                 standardExemption=4000;
  62.                 numPeople=1;
  63.         }
  64.  
  65.         cout<<"Please enter pension plan amount: ";
  66.         cin>>pensionAmount;
  67.         cout<<endl;
  68.        
  69.         tax = taxAmount(numPeople, salary, pensionAmount, standardExemption);
  70. }
  71.  
  72. int getChildren ()
  73.  
  74. {
  75.         int children;
  76.  
  77.         cout<<"Enter number of children under 14: ";
  78.         cin>>children;
  79.         cout<<endl;
  80.  
  81.         return children;
  82.  
  83. }
  84.  
  85. double taxAmount(int numPeople, double salary, double pensionAmount, int standardExemption) //You need to name these parameters, or you won't be able to use them
  86. {
  87.  
  88.  int amountoftax;
  89.  
  90.         double deductionPerNumPeople = (numPeople*1500.00);
  91.  
  92.         if(salary <= 15000.00)
  93.         {
  94.                 amountoftax = salary - ((deductionPerNumPeople + pensionAmount + standardExemption) * 0.15);
  95.         }
  96.         else if(salary > 15000.00 && salary <= 40000.00)
  97.         {
  98.                 amountoftax = 2250.00 + ((deductionPerNumPeople + pensionAmount + standardExemption - 15000.00) * 0.25);
  99.         }
  100.         else if(salary > 40000.00)
  101.         {
  102.                 amountoftax = 8460.00 + ((deductionPerNumPeople + pensionAmount + standardExemption - 40000.00) * 0.35);
  103.  
  104.                 cout<<"Your tax amount is: "<<tax<<endl;
  105.         }
  106.  
  107.         return 0; //Not returning anythign useful
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement