My assignment is to write a program that can calculate federal taxes. Single people exemption is 4000 and married is 7000. Can also add 6% of income to pension plan. Tax rates are: Between 0 - 15000 rate is 15%, Between 15001 - 40000 tax is 2250 and rate of 25% over 15000.
Over 40000 tax is 8460 and rate of 35% over 40000.
Prompt user for Marital Status, if married ask for any children under 14, Gross Salary and Percentage of income contributed to pension.
must use function getData and taxAmount. Personal Exemption is Self plus children at 1500 per person.
Here is my code:
Code:
#include <iostream>
#include <iomanip>
using namespace std;
void getdata();
double taxAmount( double status1, double GrossAmount, double pension, double kids);
int main ()
{
char S = 0;
double G = 0;
double P = 0;
double K = 0;
getdata();
return 0;
}
void getdata()
{
char status;
double GAmount;
char pension;
double child;
char filing;
double kid;
double pension1;
cout << "Enter Marital Status S/s for Singele: \n";
cout << "or M/m for Married: " << endl;
cin >> status;
switch (status)
{
case 'S':
case 's':
cout << "Enter Gross Salary Amount: ";
cin >> GAmount;
kid = 0;
cout << "Take out up to 6% into Pension Plan? \n";
cout << "Input Y/y for Yes or N/n for No: ";
cin >> pension;
if (pension == 'Y' || pension == 'y')
cout << "How Much would you like to contribute (enter as decimal: " << endl;
cin >> pension1;
if (pension == 'N' || pension == 'n')
pension1 = 0;
taxAmount(static_cast<char>(status),GAmount,pension1,kid);
break;
case 'M':
case 'm':
cout << "Will you be filing seperate N/n for No or Y/y for Yes: " << endl;
cin >> filing;
if (filing == 'Y' || filing == 'y')
cout << "Enter Combined Gross Salary Amount: " << endl;
cin >> GAmount;
cout << "Take out 6% to put into Pension Plan? \n";
cout << "Input Y/y for Yes or N/n for No: " << endl;
cin >> pension;
if (pension == 'Y' || pension == 'y')
cout << "How Much would you like to contribute (enter as decimal: " << endl;
cin >> pension1;
if (pension == 'N' || pension == 'n')
pension1 = 0;
cout << "Enter how many children under age of 14?" << endl;
cin >> child;
kid = child + 2;
taxAmount(static_cast<char>(status),GAmount,pension1,kid);
if (filing == 'N' || filing == 'n')
cout << "Enter Your Gross Salary Amount: " << endl;
cin >> GAmount;
cout << "Take out 6% to put into Pension Plan? \n";
cout << "Input Y/y for Yes or N/n for No: " << endl;
cin >> pension;
if (pension == 'Y' || pension == 'y')
cout << "How Much would you like to contribute (enter as decimal: " << endl;
cin >> pension1;
if (pension == 'N' || pension == 'n')
pension1 = 0;
cout << "Enter how many children under age of 14?" << endl;
cin >> child;
kid = child + 1;
taxAmount(static_cast<char>(status),GAmount,pension1,kid);
break;
}
}
double taxAmount(char status1, double GrossAmount, double pension, double kids)
{
double rate1 = .15;
double rate2 = .25;
double Mrate2 = 2250;
double rate3 = .35;
double Mrate3 = 8460;
double Tax;
double NewPen;
double calcKids;
double Taxed;
double SinExem = 4000;
double MarriedExem = 7000;
calcKids = (kids * 1500);
switch (status1)
{
case 'S':
case 's':
if (GrossAmount <= 15000)
NewPen = (GrossAmount * pension);
Taxed = GrossAmount * rate1;
Tax = (GrossAmount + SinExem) - (Taxed + calcKids + NewPen);
cout << "Gross Amount: " << GrossAmount << endl;
cout << "Exemption: " << SinExem << endl;
cout << "Tax: " << Taxed << endl;
cout << "Pension Contributed: " << NewPen << endl;
cout << "Total Owed: " << Tax << endl;
if(GrossAmount >= 15001 && GrossAmount <= 40000)
NewPen = (GrossAmount * pension);
Taxed = ((GrossAmount - 15000) * rate2) + Mrate2;
Tax = (GrossAmount + SinExem) - (Taxed + calcKids + NewPen);
cout << "Gross Amount: " << GrossAmount << endl;
cout << "Exemption: " << SinExem << endl;
cout << "Tax: " << Taxed << endl;
cout << "Pension Contributed: " << NewPen << endl;
cout << "Total Owed: " << Tax << endl;
if(GrossAmount >= 40001)
NewPen = (GrossAmount * pension);
Taxed = ((GrossAmount - 40000) * rate3) + Mrate3;
Tax = (GrossAmount + SinExem) - (Taxed + calcKids + NewPen);
cout << "Gross Amount: " << GrossAmount << endl;
cout << "Exemption: " << SinExem << endl;
cout << "Tax: " << Taxed << endl;
cout << "Pension Contributed: " << NewPen << endl;
cout << "Total Owed: " << Tax << endl;
break;
case 'M':
case 'm':
if (GrossAmount <= 15000)
NewPen = (GrossAmount * pension);
calcKids = (kids * 1500);
Taxed = GrossAmount * rate1;
Tax = (GrossAmount + MarriedExem) - (Taxed + calcKids + NewPen);
cout << "Gross Amount: " << GrossAmount << endl;
cout << "Exemption: " << MarriedExem << endl;
cout << "Tax: " << Taxed << endl;
cout << "Pension Contributed: " << NewPen << endl;
cout << "Total Owed: " << Tax << endl;
if(GrossAmount >= 15001 && GrossAmount <= 40000)
NewPen = (GrossAmount * pension);
calcKids = (kids * 1500);
Taxed = ((GrossAmount - 15000) * rate2) + Mrate2;
Tax = (GrossAmount + MarriedExem) - (Taxed + calcKids + NewPen);
cout << "Gross Amount: " << GrossAmount << endl;
cout << "Exemption: " << MarriedExem << endl;
cout << "Tax: " << Taxed << endl;
cout << "Pension Contributed: " << NewPen << endl;
cout << "Total Owed: " << Tax << endl;
if(GrossAmount >= 40001)
NewPen = (GrossAmount * pension);
calcKids = (kids * 1500);
Taxed = ((GrossAmount - 40000) * rate3) + Mrate3;
Tax = (GrossAmount + MarriedExem) - (Taxed + calcKids + NewPen);
cout << "Gross Amount: " << GrossAmount << endl;
cout << "Exemption: " << MarriedExem << endl;
cout << "Tax: " << Taxed << endl;
cout << "Pension Contributed: " << NewPen << endl;
cout << "Total Owed: " << Tax << endl;
break;
}
return 0;
}
and this is the error I keep getting:
1>ftax.obj : error LNK2019: unresolved external symbol "double __cdecl taxAmount(double,double,double,double)" (?taxAmount@@YANNNNN@Z) referenced in function "void __cdecl getdata(void)" (?getdata@@YAXXZ)
1>C:\data\ftax\Debug\ftax.exe : fatal error LNK1120: 1 unresolved externals
I have no clue what it means and I am in my first course of C++ so am really new to this any help will be appreciated.