#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int getChildren ();
double taxAmount(int numPeople, double salary, double pensionAmount, int standardExemption);
void getData ();
int main ()
{
getData();
return 0;
}
void getData ()
{
char status = 0;
char answer = 0;
int numPeople = 0;
int numChildren = 0;
double tax = 0.0;
double salary = 0.0;
double pensionAmount = 0.0;
double deductAmount = 0.0;
double standardExemption = 0.0;
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);
cout << "Your tax total is: " << tax << endl;
cout << "Press enter to continue..." << endl;
cin.ignore();
cin.get();
}
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)
{
double 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);
}
return amountoftax;
}