# Month and Annual costs

• October 5th, 2012, 12:12 PM
MostImpressive
Month and Annual costs
The point of this is to calculate the total of the monthly costs of these 6 expenses and then to show the annual cost. However, there's just a couple of things that's giving me problems and it's the calcMonCost in my code. The error says that it is more than one instance of overload function and also that an unresolved external symbol. Everything else is fine. What does this mean?

code:

Quote:

#include <iostream>
#include <iomanip>

using namespace std;

void calcMonCost (double, double, double, double, double, double &);
void calcAnnCost (double, double, double, double, double, double &);
void getData(double &lnPymnt, double &insure, double &gas, double &oil, double &tires, double &maint);

int main ()
{
double lnPymnt;
double insure;
double gas;
double oil;
double tires;
double maint;

getData(lnPymnt, insure, gas, oil, tires, maint);

problem area --->calcMonCost(lnPymnt, insure, gas, oil, tires, maint);

system("pause");
return 0;
}

void getData(double &lnPymnt, double &insure, double &gas, double &oil, double &tires, double &maint)
{
cout << "Enter monthly loan payments: ";
cin >> lnPymnt;

cout << "Enter monthly insurance: ";
cin >> insure;

cout << "Enter monthly gas expenses: ";
cin >> gas;

cout << "Enter monthly cost of oil: ";
cin >> oil;

cout << "Enter monthly cost of tires: ";
cin >> tires;

cout << "Enter monthly maintenance cost: ";
cin >> maint;
}

void calcMonCost (double lnPymnt, double &insure, double &gas, double &oil, double &tires, double &maint)
{
double monTotal;
monTotal= lnPymnt + insure + gas + oil + tires + maint;
cout << "Total monthly expenses cost is " << monTotal <<"." << endl;
}

void calcAnnCost (double monTotal)
{
double annTotal;
annTotal = monTotal * 12;
cout << "The annual expenses cost is " << annTotal << "." << endl;
}
• October 9th, 2012, 01:58 AM
Marc G
Re: Month and Annual costs
The reason is that your calcMonCost signature is different on two places. First you define it as:
Code:

`void calcMonCost (double, double, double, double, double, double &);`
And lower you define it as:
Code:

`void calcMonCost (double lnPymnt, double &insure, double &gas, double &oil, double &tires, double &maint)`
Which is not the same, because the first version accepts 5 doubles and 1 reference to a double, while the second version accepts 1 double and 5 references to doubles.