Question: PROJECT DESCRIPTION: When people fill out their tax return, they have the option of itemizing their deductions or using a standard deduction. If people are
PROJECT DESCRIPTION: When people fill out their tax return, they have the option of itemizing their deductions or using a standard deduction. If people are buying a house and have a mortgage, have donated a lot of money to charities, have high medical bills or other deductions, it may be better to itemize and list all their deductions. For many people it may be better to take the 'standard deduction' The program should ask for the following information in this order: When all the data has been collected, the program displays I have completed most of the code for the Tax Estimator project. The program needs to be updated to ask if the the user wants to itemize or use the standard deduction. If the user selects to itemize, then the program is to ask for the itemized deductions. If the user selects the standard deduction, then the program looks up the amount of deduction from an array, based on the filing status (single, married, etc.) The project currently allows the user to input the amount of the itemized deductions, but the program has not been completed to use the standard deductions. If the standard deduction option is selected when running the program, the deductions should place the standard deductions in an array and look up the deduction from the array. The array is to be filled with the following data: Taxpayer Status Standard Deduction ========================================= Single 6300.00 Married filing jointly 12600.00 Married filing separately 6300.00 Head of Household 9250.00 Qualifying Widow(er) 12600.00
C++ code
HINTS: The lab project requires that you implement Standard Deductions using an array. I suggest that you modify the inputDeductions function. It's formal definition is: double inputDeductions(int s)
Ask the user to select either Standard Deduction or Itemized Deduction
If itemized deductions are selected, the use the rest of the code in the function that asks for the amount of the deductions, then reads the amount of deductions from the keyboard.
If standard deductions are selected, use the TaxPayerStatus (known as s in the inputDeductions function) to lookup the deductions from the array you create for standard deductions. You only need to create a single-dimensional array of type double that contains the amount of standard deductions. NOTE: the actual TaxPayerStatus has a value from 1 to 5 and arrays are indexed starting at 0. You need to make some adjustment when indexing into the array.
// Danielle Heinritz
//CIS 054 C/C++ Programming
// July 10, 2018
#include
#include
using namespace std;
enum taxStatus {
Single = 1,
MarriedFilingJointly,
MarriedFilingSeparately,
HeadOfHousehold,
QualifyingWidow // or Widower
};
struct taxTable {
double from;
double to;
double tax;
double percent;
};
const double exemptionRate = 4000.00;
const int bracketCount = 7;
int inputStatus();
int inputExemptions();
double inputIncome();
double inputDeductions(int);
double standardDeduction(int);
double computedTax(int, double taxableIncome);
taxTable *tableSelection(int);
int main(int argc, char* argv[])
{
int status;
double totalIncome;
int exemptions;
double deductions;
double taxableIncome;
double tax;
double withholding;
double refundOrTaxDue;
cout << "FEDERAL TAX ESTIMATOR" << endl;
cout << "The data in this project is from a previous tax year. Tax tables" << endl;
cout << "are adjusted each year due to inflation and legal changes. The" << endl;
cout << "output from this program is for information purposes only." << endl << endl;
do
{
// input the data
status = inputStatus(); // input the tax payer status (1-5)
if (status == 0)
break; // end the program
exemptions = inputExemptions();
totalIncome = inputIncome();
deductions = inputDeductions(status); // taxpayer status to inputDeductions
cout << "Enter the amount withheld: ";
cin >> withholding;
// compute the tax
taxableIncome = totalIncome - exemptions*exemptionRate - deductions;
if (taxableIncome < 0)
taxableIncome = 0;
tax = computedTax ((taxStatus)status, taxableIncome);
refundOrTaxDue = withholding - tax;
// display the results
cout << setiosflags(ios::fixed | ios::showpoint) << endl;
cout << setprecision(2);
cout << endl;
cout << "Income: " << setw(9) << totalIncome << endl;
cout << "Exemptions: " << setw(9) << -exemptions * exemptionRate << endl;
cout << "Deductions: " << setw(9) << -deductions << endl;
cout << "--------------------------" << endl;
cout << "Taxable Income: " << setw(9) << taxableIncome << endl << endl;
cout << "Tax Estimate: " << setw(9) << tax << endl;
cout << "Withholding: " << setw(9) << withholding << endl;
if (refundOrTaxDue >= 0)
cout << "Estimated refund:" << setw(9) << refundOrTaxDue << endl;
else
cout << "Please pay: " << setw(9) << -refundOrTaxDue << endl;
cout << endl;
} while (status >=1 && status <= 5);
return 0;
}
////// input taxpayer status (0-5) ////
int inputStatus()
{
int status;
do {
cout << "=======================================================" << endl;
cout << "Enter your tax status:" << endl
<< "1 = Single" << endl
<< "2 = Married filing jointly" << endl
<< "3 = Married filing separately" << endl
<< "4 = Head of Household" << endl
<< "5 = Qualifying widow(er)" << endl
<< "0 = END THE PROGRAM" << endl
<< "> ";
cin >> status;
if (cin.fail() || status < 0 || status > 5)
cout << "Illegal value, try again" << endl;
} while (status < 0 || status > 5);
return status;
}
////// input exemptions ////
int inputExemptions()
{
int exemptions;
cout << "Enter the number of exemptions: (you + dependants): ";
cin >> exemptions;
return exemptions;
}
////// input income ////
double inputIncome()
{
double income;
cout << "Enter your total income: ";
cin >> income;
return income;
}
////// input deductions ////
double inputDeductions(int taxpayerStatus)
{
double deductions;
cout << "Enter the amount of your Itemized Deductions: ";
cin >> deductions;
return deductions;
}
// The asterisk * indicates that a pointer is to be returned.
taxTable *tableSelection (int s)
{
const double maxDouble = 1E12; // just some big number = 1 * 10^12
//from to tax percent
static taxTable SingleTaxTable[] = {
{0.00, 9225.00, 0.00, 10.0},
{9225.00, 37450.00, 922.50, 15.0},
{37450.00, 90750.00, 5156.25, 25.0},
{90750.00, 189300.00, 18481.25, 28.0},
{189300.00, 411500.00, 46075.25, 33.0},
{411500.00, 413200.00, 119401.25, 35.0},
{413200.00, maxDouble, 119996.25, 39.6}
};
static taxTable MarriedFilingJointlyTaxTable[] = {
{0.00, 18450.00, 0.00, 10.0},
{18450.00, 74900.00, 1845.00, 15.0},
{74900.00, 151200.00, 10312.50, 25.0},
{151200.00, 230450.00, 29387.50, 28.0},
{230450.00, 411500.00, 51577.50, 33.0},
{411500.00, 464850.00, 111324.00, 35.0},
{464850.00, maxDouble, 129996.50, 39.6}
};
static taxTable MarriedFilingSeparatelyTaxTable[] = {
{0.00, 9225.00, 0.00, 10.0},
{9225.00, 37450.00, 922.50, 15.0},
{37450.00, 75600.00, 5156.25, 25.0},
{75600.00, 115225.00, 14693.75, 28.0},
{115225.00, 205750.00, 25788.75, 33.0},
{205750.00, 232425.00, 55662.00, 35.0},
{232425.00, maxDouble, 64998.25, 39.6}
};
static taxTable HeadOfHouseholdTaxTable[] = {
{0.00, 13150.00, 0.00, 10.0},
{13150.00, 50200.00, 1315.00, 15.0},
{50200.00, 129600.00, 6872.50, 25.0},
{129600.00, 209850.00, 26772.50, 28.0},
{209850.00, 411500.00, 49192.50, 33.0},
{411500.00, 439000.00, 115737.00, 35.0},
{439000.00, maxDouble, 125362.00, 39.6}
};
static taxTable QualifyingWidowTaxTable[] = {
{0.00, 18450.00, 0.00, 10.0},
{18450.00, 74900.00, 1845.00, 15.0},
{74900.00, 151200.00, 10312.50, 25.0},
{151200.00, 230450.00, 29387.50, 28.0},
{230450.00, 411500.00, 51577.50, 33.0},
{411500.00, 464850.00, 111324.00, 35.0},
{464850.00, maxDouble, 129996.50, 39.6}
};
switch (s) { // return a pointer to the table based on the filing status
case Single: return SingleTaxTable;
case MarriedFilingJointly: return MarriedFilingJointlyTaxTable;
case MarriedFilingSeparately: return MarriedFilingSeparatelyTaxTable;
case HeadOfHousehold: return HeadOfHouseholdTaxTable;
case QualifyingWidow: return QualifyingWidowTaxTable;
default: return NULL;
};
return NULL;
}
double computedTax (int s, double taxableIncome)
{
taxTable *table = tableSelection(s);
double baseTax;
double tax=0.0;
// find the entry in the tax table
for (int i=0; i { if (taxableIncome>table[i].from && taxableIncome<=table[i].to) { baseTax = table[i].tax; tax = baseTax + (taxableIncome - table[i].from)*table[i].percent/100.0; } } return tax; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
