I'm new with C++ so no flame. I'm getting this error
[Linker error] undefined reference to `DetermineCost(double, double)'
ld returned 1 exit status
Here is my code
Code:
#include <iostream>
#include <iomanip>
using namespace std;
void ExplainProgram();
double GetIncome();
double DetermineCost(double income, double rate);
void DisplayResults(double income, double tax);
const int MAX1 = 5000; // max income for the first category
const int MAX2 = 10000; // max income for the second category
const int MAX3 = 20000; // max income for the third category
const int MAX4 = 40000; // max income for the fourth category
const double RATE1 = .03;
const double RATE2 = .055;
const double RATE3 = .108;
const double RATE4 = .237;
int main()
{
double income; // total income of the person
double rate; // tax rate based on persons income
double tax; // tax owned rounded to the nearest dollar
ExplainProgram();
income = GetIncome();
tax = DetermineCost(income, rate);
DisplayResults(income, tax);
system("PAUSE");
return 0;
}
// Function: ExplainProgram
// Task: Explain the purpose of the program to the user
// Preconditions: none
// Postconditions: the explaination appears on the screen
void ExplainProgram()
{
cout << "Given the income of a person, this program will find and print\n"
<< "the cost of taxes\n\n";
}
// Function: GetIncome
// Task: Get the income of the person from the user
// Preconditions: none
// Postconditions: the income of the person (double) will be returned
double GetIncome()
{
double totalIncome;
cout << "Enter the persons income: ";
cin >> totalIncome;
if (totalIncome < 0)
{
cerr << "ERROR: persons income cannot be negative!!!\n";
system("PAUSE");
exit(1);
}
return totalIncome;
}
// Function: DetermineCost
// Task: Given the person's income determine the total tax cost
// Preconditions: the income of the person is provided as a double passed by value
// Postconditions: the tax amount in dollars (double) is returned
double DetermineCost(double incomeOfPerson, double tax, double income)
{
if (incomeOfPerson <= MAX1)
{
tax = income;
return tax;
}
else if (incomeOfPerson <= MAX2)
{
tax = income * RATE1;
return tax;
}
else if (incomeOfPerson <= MAX3)
{
tax = income * RATE2;
return tax;
}
else if (incomeOfPerson <= MAX4)
{
tax = income * RATE3;
return tax;
}
else
{
tax = income * RATE4;
return tax;
}
}
// Function: DisplayResults
// Task: display the tax owned to the nearest dollar for the user to see
// Preconditions: the income of the person (double) and the tax rate (double)
// are passed by value
// Postconditions: the income and rate are displayed to the screen
void DisplayResults(double income, double tax)
{
cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(2);
cout << "An income of $" << income << " will own $" << tax
<< " for taxes.\n";
}
Help with this will be greatly appreciated.