Hi guys,
I'm working on this problem I've been struggling with for a while now. I'm still confused about parameters and I'm getting all these error messages, saying that a lot of my variables are undefined. I'm sorry, I know this probably looks like a mess right now, but if anyone could help me out as to what I need to change around to get this working, I would be so appreciative.
I'm also not sure if I need the prototypes?
The assignment is in the comments at the top:
// Write a program that can be used to calculate the federal tax. The tax calculated as follows:
// For single people, the standard exemption is $4000; for married people, the standard exemption
// is $7000. A person can also put up to 6% of his or her gross standard income in a pension plan.
// The tax rates are as follows: If the taxable income is
// 1) Between $0 and $15000, the tax rate is 15%
// 2)between $15001 and $40000, the tax is $2250 plus 25% of the taxable income over $15000
// 3)Over $40,000, the tax is $8460 plus 35% of the taxable income over $40000
// Prompt the user to enter the following information:
// 4)Martial status
// 5)If the marital status is "married", ask for the number of children under the age of 14
// 6)Gross salary(if the martial status is "married" and both spouses have income, enter the combined salary.)
// 7) Percentage of gross income contributed to a pension fund.
//The program must consist of at least the following functions:
//a) function getData: this function asks the user to enter the relevant data.
//b) function taxAmount: this function computes and returns the tax owned.
//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 $1500 per person.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void getData(char marital, int numChild, int& exempt, int& noOfPeople, double& groSalary, double& penAmt);
double taxAmount(double taxIncome, int perExempt, double taxRate);
int main()
{
double groSalary; //variable for gross salary
double penAmt; //variable for percent contributed to pension plan
int exempt; //variable for standard exemption
int noOfPeople; //variable for number of people
double taxIncome; //variable for taxable income
double taxRate; //variable for federal tax amount owed
getData(char marital, int numChild, int& exempt, int& noOfPeople, double& groSalary, double& penAmt);
double taxAmount(double, int, double);
cout << "Your federal tax owed is: " << taxRate << endl;
return 0;
}
void getData(char marital, int numChild, int& exempt, int& noOfPeople, double& groSalary, double& penAmt)
{
char marital; //variable for marital status
int numChild; //variable for the number of children under 14
cout << fixed << showpoint;
cout << setprecision(2);
cout << "Enter your marital status: 'M' for Married or 'S' for Single: ";
cin >> marital;
cout << endl;
if (marital == 'M' || marital == 'm')
{
cout << "Enter number of children under the age of 14 years: ";
cout <<endl;
cin >> numChild;
exempt = 7000;
noOfPeople = 2 + numChild;
}
else if (marital == 'S' || marital == 's')
{
exempt = 4000;
numChild = 0;
noOfPeople = 1;
}
cout << "Enter gross salary. (Enter combined salary for both spouses";
cout << "if married): ";
cout << endl;
cin >> groSalary;
cout << "Enter the percentage of your gross income which you have";
cout << " contributed to a pension fund (Only enter the amount if 6%";
cout << " or less of your combined gross income: ";
cout << endl;
cin >> penAmt;
if (penAmt > 6)
{
cout << "You may only enter a percentage which is greater or equal";
cout << " to 6. Enter the percentage of your gross income which you have";
cout << " contributed to a pension fund. (Only enter the amount if 6%";
cout << " or less of your combined gross income: ";
cout << endl;
cin >> penAmt;
}
}
double taxAmount(double taxRate, int perExempt, int noOfPeople, double taxRate)
{
double taxRate; //variable to store taxRate
double taxAmt; //variable to store total tax amount
int perExempt //variable for personal Exemptions
taxRate = 0;
perExempt = (noOfPeople * 1500) + exempt;
taxIncome = groSalary - (groSalary * (penAmt * .01)) - perExempt);
if (taxIncome <= 15000)
{taxRate = .15 * taxIncome;
}
else if (taxIncome > 15000 && taxIncome <= 40000)
{taxRate = ((taxIncome - 15000) * .25) + 2250;}
else{
taxRate = ((taxIncome - 40000) * .35) + 8460;
}
return taxRate;
}