1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <iostream>
#include <iomanip>
using namespace std;
void getData(char &maritalStatus, int &numberOfPersons, double &gross_Salary, double &pension_contribution)
{
cout << "Please enter your Marital Status." << endl;
cout << "[M]arried or [S]ingle: ";
cin >> maritalStatus;
cout << "Please enter your salary: ";
cin >> gross_Salary;
numberOfPersons = 1;
cout << "Please enter your Pension Plan contribution(limit upto 6%): ";
cin >> pension_contribution;
while (pension_contribution > 6.00)
{
cout << "The limit is upto 6% only." << endl;
cout << "Please enter your Pension Plan contribution(limit upto 6%): ";
cin >> pension_contribution;
}
pension_contribution = pension_contribution / 100 * gross_Salary;
cout << endl;
}
double taxAmount(char maritalStatus, int numberOfPersons, double gross_Salary, double pension_contribution)
{
double standardExemption = 0;
double income;
if (maritalStatus == 'm' || maritalStatus == 'M')
standardExemption = 7000;
else
standardExemption = 4000;
income = gross_Salary - ((1500.00 * numberOfPersons) + pension_contribution + standardExemption);
return (income);
}
double calcTax(double taxable_Income)
{
if (taxable_Income >= 0 && taxable_Income <= 15000)
return taxable_Income * 0.15;
else if (taxable_Income >= 15001 && taxable_Income <= 40000)
return 2250.00 + taxable_Income * 0.25;
else
return 8460.00 + taxable_Income * 0.35;
}
int main()
{
char maritalStatus = ' ';
int numberOfPersons = 0;
double gross_Salary = 0, pension = 0;
double federal_tax = 0, taxable_Income = 0;
cout << fixed << showpoint << setprecision(2);
getData(maritalStatus, numberOfPersons, gross_Salary, pension);
taxable_Income = taxAmount(maritalStatus, numberOfPersons, gross_Salary, pension);
federal_tax = calcTax(taxable_Income);
cout << "Marital Status: " << maritalStatus << endl;
cout << "Number of Persons in the family: " << numberOfPersons << endl;
cout << "Income earned: " << gross_Salary << endl;
cout << "Pension Plan contribution: " << pension << endl;
cout << "Taxable Income: " << taxable_Income << endl;
cout << "Thus, the Federal Tax payable is: " << federal_tax << endl;
return 0;
}
|