I am working on this problem for a class, and I am running into a lot of errors. I spent a good deal of time trying to troubleshoot/de-bug my code, but have been unable to get rid of all of the errors. I would love a few tips or ways to fix the various errors that are popping up. Here is the problem:
"Write a 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 his or her 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.
Prompt the user to enter the following information:
Marital status
If the marital status is ‘‘married,’’ ask for the number of children under the age of 14
Gross salary (If the marital status is ‘‘married’’ and both spouses have income, enter the combined salary.)
Percentage of gross income contributed to a pension fund
Your program must consist of at least the following functions:
Function getData: This function asks the user to enter the relevant data.
Function taxAmount: This function computes and returns the tax owed.
To calculate the taxable income, subtract the sum of the standard exemption, the amount contributed to a pension plan, and the personal exemption, which is $1,500 per person. (Note that if a married couple has two children under the age of 14, then the personal exemption is $1,500 * 4 = $6,000.)"
And here is my code:
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
|
#include <iostream>
#include <iomanip>
using namespace std;
// program constants
// declare getData and taxAmount functions
void getData(char& mStatus, int& nOfChildren, double& salary, double& pContribPension);
double taxAmount(char mStatus, int nOfChildren, double salary, double pContribPension);
int main()
{
char maritalStatus;
int numberOfChildren;
double grossSalary;
double pContributedToPension;
cout << fixed << showpoint;
cout << setprecision(2);
// call getData
getData(char mStatus, int nOfChildren, double salary, double pContribPension);
// output tax amount using taxAmount
taxAmount(char mStatus, int nOfChildren, double salary, double pContribPension);
return 0;
}
void getData(char& mStatus, int& nOfChildren, double& salary,
double& pContribPension)
{
// write your getData function here
cout << "Are you currently married?" << endl;
cin >> mStatus;
if (mStatus='m'){
cout << endl << "How many children under the age of 14 do you have?" << endl;
cin >> nOfChildren;
cout << endl << "What is your combined salary?" << endl;
cin >> salary;
cout << endl;
}
else {
cout << endl << "What is your gross salary?" << endl;
cin >> salary;
cout << endl << "What percentage of your gross income goes into a pension fund?" << endl;
cin >> pContribPension;
cout << endl;
}
}
double taxAmount(char mStatus, int nOfChildren, double salary,
double pContribPension)
{
//write your taxAmount function here
double taxIncome;
double taxRate;
if (mStatus='m'){
taxIncome=salary-7000;
}
else {
taxIncome=salary-4000;
taxIncome=taxIncome-(pContribPension*salary)-(1500);
}
if (mStatus='m')
taxIncome=taxIncome-1500;
if (nOfChildren=2)
taxIncome=taxIncome-(6000-1500);
cout << "Taxable income is $" << taxIncome << "." << endl;
if (taxIncome<=15000)
taxRate=.15;
if (taxIncome<=40000 && taxIncome>=15001)
taxRate=.25;
if (taxIncome>40000)
taxRate=.35;
if (taxIncome<=15000)
taxAmount=taxIncome*taxRate;
if (taxIncome<=40000 && taxIncome>=15001)
taxAmount=((taxIncome-15000)*taxRate)+2250;
if (taxIncome>40000)
taxAmount=((taxIncome-40000)*taxRate)+8460;
return taxAmount;
}
| |
Thanks for any and all help!