Question
For this assignment, complete problem #5 on p. 518. I have provided the input values and outvalues. The input values will be in a file,
For this assignment, complete problem #5 on p. 518. I have provided the input values and outvalues. The input values will be in a file, so you can process multiple records. You can read the records in the main routine, but the calculation of the tax must be performed in a function. The output can be done in main. Marital Status, No. of children, Combined gross salary, % contribution to pension M 2 28000 5 S 1 75000 5 S 0 45000 6 M 0 120000 5 M 3 90000 5 #5 States: Write program that can be used to calculate the federal tax. The tax is calculated as follows: For single people, the standard exemption is $4,000; for married people, the standard exemption is $7,000. A person can also put up to 6% of their gross income in a pension plan. The tax rates are as follows: If the taxable income is *Between $0 and $15,000 the tax rate is 15% *Between $15,001 and $40,000 the tax is $2,250 plus %25 of the taxable income over $15,000. *Over $40,000 the tax is $8,460 plus 35% of the taxable income over $40,000
I just need the correct code I only get 50% on mine and it works but doesn't compile the math
#include#include using namespace std; void getData(int numPerson, int numChildren, double salary, int pension, double tax); double taxAmount(int numPerson, double salary, int pension, double tax, double totalTax); int main () { int numberOfPerson = 0; int numberOfChildren = 0; int pensionPercent = 0; double grossIncome = 0; double taxableIncome = 0; double taxOwed = 0; double taxPayment; getData(numberOfPerson, numberOfChildren, grossIncome, pensionPercent, taxableIncome); taxPayment = taxAmount(numberOfPerson, grossIncome, pensionPercent, taxableIncome, taxOwed); cout << "The tax is: " << taxPayment << endl; return 0; } void getData(int numPerson, int numChildren, double salary, int pension, double tax) { char maritalStatus; cout << "Enter marital status. M = Married & S = Single. "; cin >> maritalStatus; cout << endl; if (maritalStatus == 'm' || maritalStatus == 'M') { cout << "Any children under the age of 14? "; cin >> numChildren; cout << endl; numPerson = 2 + numChildren; } else if (maritalStatus == 's' || maritalStatus == 'S') { numPerson = 1; } cout << "Enter gross income. If married and both spouses are working, enter combine income. "; cin >> salary; cout << endl; cout << "Enter the percentage of gross income contributed to the pension. "; cin >> pension; cout << endl; } double taxAmount(int numPerson, double salary, int pension, double tax, double totalTax) { const int PERSONAL_EXEMPTION = 1500; const int SINGLE_EXEMPTION = 4000; const int MARRIED_EXEMPTION = 7000; if (numPerson == 1) { tax = salary - PERSONAL_EXEMPTION - SINGLE_EXEMPTION - salary * (pension / 100); } else if (numPerson >= 2) { tax = salary - MARRIED_EXEMPTION - (PERSONAL_EXEMPTION * numPerson) - salary * (pension / 100); } if (tax >= 0 && tax <= 15000) { totalTax = tax * 0.15; } else if (tax >= 15001 && tax <= 40000) { totalTax = 2250 + (tax - 15000) * 0.25; } else if (tax >= 40001) { totalTax = 8460 + (tax - 40000) * 0.35; } return totalTax; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started