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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void getData(char maritalStatus, int children, double& salary, double& pension, double& standardExemption, double& personalExemption);
double taxAmount (double salary1, double pension1, double standardExemption1, double personalExemption1);
int main ()
{
double salary1 = 0;
double pension1 = 0;
double standardExemption1 = 0;
double personalExemption1 = 0;
char maritalStatus = 0;
int children = 0;
double salary = 0;
double pension = 0;
double standardExemption = 0;
double personalExemption = 0;
double tax = 0;
getData (maritalStatus, children, salary, pension, standardExemption, personalExemption);
taxAmount (salary1, pension1,standardExemption1, personalExemption1);
cout << "The amount of Federal Tax you owe is: " << tax << endl;
}
void getData(char maritalStatus, int children, double& salary, double& pension, double& standardExemption, double& personalExemption)
{
children = 0;
maritalStatus = 0;
salary = 0;
pension = 0;
standardExemption = 0;
personalExemption = 0;
cout << "Please enter whether you are [M]arried or [S]ingle: " << endl;
cin >> maritalStatus;
switch (maritalStatus)
{
case 'M':
case 'm':
cout << "Please enter how many children you have under the age of 14: " << endl;
cin >> children;
cout << "Please enter the combined gross salary of you and your spouse: " << endl;
cin >> salary;
cout << "Please enter the percentage of gross income you contributed to a pension fund: " << endl;
cin >> pension;
standardExemption = 7000;
personalExemption = 3000 + children * 1500;
break;
case 'S':
case 's':
cout << "Please enter your gross salary: " << endl;
cin >> salary;
cout << "Please enter the percentage of gross income you contributed to a pension fund: " << endl;
cin >> pension;
standardExemption = 4000;
personalExemption = 1500;
break;
default:
cout << "Invalid choice, please select M for married, or S for single."
<< endl;
}
}
double taxAmount (double salary1, double pension1, double standardExemption1, double personalExemption1)
{
double pensionAmount = 0;
double exemptionAmount = 0;
double taxableIncome = 0;
double tax = 0;
pensionAmount = salary1 * (pension1 * .01);
exemptionAmount = standardExemption1 + personalExemption1 + pensionAmount;
taxableIncome = salary1 - exemptionAmount;
if (taxableIncome <= 15000)
tax = taxableIncome * .15;
if (taxableIncome > 15000 && taxableIncome <= 40000)
tax = 2500 + (.25 * (taxableIncome - 15000));
if (taxableIncome > 40000)
tax = 8460 + (.35 * (taxableIncome - 40000));
return tax;
}
|