Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int getChildren ();
- double taxAmount(int, double, double, int);
- void getData ();
- int main ()
- {
- getData();
- return double;
- }
- void getData ()
- {
- char status, answer;
- int numChildren;
- double salary, pensionAmount, deductAmount;
- int numPeople, standardExemption;
- double tax;
- cout<<"Enter 'm'arried or 's'ingle:";
- cin>>status;
- cout<<endl;
- if (status=='m'||status=='M')
- {
- numChildren=getChildren();
- standardExemption=7000;
- cout<<"Do both spouses earn an income? Enter 'Y'es or 'N'o: ";
- cin>>answer;
- cout<<endl;
- if (answer=='y'||answer=='Y')
- {
- cout<<"Please enter combined salary: ";
- cin>>salary;
- cout<<endl;
- }
- else if (answer=='n'||answer=='N')
- {
- cout<<"Please enter your salary: ";
- cin>>salary;
- cout<<endl;
- }
- numPeople=2+numChildren;
- }
- else
- {
- cout<<"Please enter your salary: ";
- cin>>salary;
- cout<<endl;
- standardExemption=4000;
- numPeople=1;
- }
- cout<<"Please enter pension plan amount: ";
- cin>>pensionAmount;
- cout<<endl;
- tax = taxAmount(numPeople, salary, pensionAmount, standardExemption);
- }
- int getChildren ()
- {
- int children;
- cout<<"Enter number of children under 14: ";
- cin>>children;
- cout<<endl;
- return children;
- }
- 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
- {
- int amountoftax;
- double deductionPerNumPeople = (numPeople*1500.00);
- if(salary <= 15000.00)
- {
- amountoftax = salary - ((deductionPerNumPeople + pensionAmount + standardExemption) * 0.15);
- }
- else if(salary > 15000.00 && salary <= 40000.00)
- {
- amountoftax = 2250.00 + ((deductionPerNumPeople + pensionAmount + standardExemption - 15000.00) * 0.25);
- }
- else if(salary > 40000.00)
- {
- amountoftax = 8460.00 + ((deductionPerNumPeople + pensionAmount + standardExemption - 40000.00) * 0.35);
- cout<<"Your tax amount is: "<<tax<<endl;
- }
- return 0; //Not returning anythign useful
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement