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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
#include <iostream>
#include <string>
using namespace std;
void getData(double exempts[3])
{
char maritalStatus, answer, answer2;
int childCount = 0, totalPerson = 0;
double grossIncome, standardExempt, personalExempt, pension;
cout << "What is your marital status? M = Married & S = Single : ";
cin >> maritalStatus;
cout << endl;
switch (maritalStatus)
{
case 'm':
case 'M':
{
cout << "Do both spouses earn income? [Y/N] : ";
cin >> answer;
cout << endl;
if (answer == 'y' || answer == 'Y')
{
cout << "Enter the total income combined: ";
cin >> grossIncome;
cout << endl;
cout << "How many children do you claim?";
cin >> childCount;
cout << endl;
}
if (answer == 'n' || answer == 'N')
{
cout << "Enter your salary: ";
cin >> grossIncome;
cout << endl;
cout << "How many children do you claim?";
cin >> childCount;
cout << endl;
standardExempt = grossIncome - 7000;
exempts[0] = standardExempt;
personalExempt = 1500 * totalPerson;
exempts[1] = personalExempt;
totalPerson = 2 + childCount;
exempts[2] = totalPerson;
}
case 's':
case 'S':
{
cout << "Please enter your salary: ";
cin >> grossIncome;
cout << endl;
cout << "How many children do you claim? ";
cin >> childCount;
cout << endl;
standardExempt = grossIncome - 7000;
exempts[0] = standardExempt;
personalExempt = 1500 * totalPerson;
exempts[1] = personalExempt;
totalPerson = 1 + childCount;
exempts[2] = totalPerson;
}
}
cout << "Would you like put up 6% in your pension? [Y/N] ";
cin >> answer2;
cout << endl;
if (answer2 == 'y' || answer2 == 'Y')
{
pension = .06 * grossIncome;
exempts[3] = pension;
}
}
double taxAmount(int totalPerson, double grossIncome, double personalExempt, double standardExempt, double pension)
{
double taxableIncome, marginalIncome, marginTax, baseTax, totalTax;
taxableIncome = grossIncome - (personalExempt + standardExempt + pension);
if (taxableIncome <= 15000)
{
marginTax = .15 * taxableIncome;
totalTax = marginTax + pension;
}
if (taxableIncome >= 15001 || taxableIncome <= 40000)
{
marginalIncome = taxableIncome - 15000;
marginTax = .25 * taxableIncome;
baseTax = 2250;
totalTax = baseTax + marginTax + pension;
}
if (taxableIncome > 40000)
{
marginalIncome = taxableIncome - 40000;
marginTax = .35 * taxableIncome;
baseTax = 8460;
totalTax = baseTax + marginTax + pension;
}
return(totalTax);
}
int main()
{
double tax;
double grossIncome = 0.00, pension = 0.00, standardExempt = 0.00, personalExempt = 0.00, salary = 0.00;
int totalPerson = 0;
double exempts[3];
getData(exempts);
standardExempt = exempts[0];
personalExempt = exempts[1];
totalPerson = exempts[2];
pension = exempts[3];
tax = taxAmount(totalPerson, grossIncome, personalExempt, standardExempt, pension);
cout << "From the information provided, your total taxes due is: $" << tax << endl;
return 0;
}
|