Hi Everybody I am new to C++ and have a problem from the book my instructor gave that I am having some problems with. I am sure you guys are all familiar with the "mortgage calculator" here is my code. The Errors I am getting are as follows. I have been working on this for a few days now and any help would really be great!!


****************************************************************************************

1>c:\users\thomas family\documents\visual studio 2010\projects\mortgage\mortgage\mort calc.cpp(23): error C2064: term does not evaluate to a function taking 0 arguments
1>c:\users\thomas family\documents\visual studio 2010\projects\mortgage\mortgage\mort calc.cpp(25): error C2064: term does not evaluate to a function taking 4 arguments
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

***************************************************************************************

#include <iostream>
#include <string>
#include <cmath>

using namespace std;

void Greeting();
double AskPrinciple();
double AskInterestRate();
double AskYears();
double CalcResults(double Principle, double IR, double Years, double MP);
void WriteResults();

int main()
{
double Principle, Years, MonthlyPayment, TotalInterestPaid, IR, results, MP;
string WriteResults;

Principle = AskPrinciple();
IR = AskInterestRate();
Years = AskYears();
results = WriteResults();
MonthlyPayment = CalcResults ( Principle, IR, Years, MP);
WriteResults (Principle, IR, Years, MP );

return 0;
}

double AskPrinciple()
{
	double num;

	cout << "\n What is the Principle \n";
	cin >> num;
	cin.ignore();

	return num;
}
double AskInterestRate()
{
	double  num, finalnum;
	cout << "\n What is the Interest Rate? (write in whole number form for example 7.42% is 7.42 not .0742) \n";
	cin >> num;
	finalnum = num/100;
	cin.ignore();

	return finalnum;
}

double AskYears()
{
	double num;
	cout << "\n How Many Years is the Loan? \n";
	cin >> num;
	cin.ignore();

	return num;
}

double calcresults(double  Principle, double IR, double Years, double MP)
{


	MP = (Principle * IR)/(12*pow(1-((1+(IR/12))),-1*Years*12));

	return MP;
}
void Greeting()
{
	cout << "\n Welcome to the Mortgage Calculator \n";
}

void WriteResults(double  Principle, double IR, double Years, double MP)
{
	cout.setf(ios::fixed);
	cout.precision(2);
	cout<< "\n Your Loan info: \n";
cout<< "Principle: "<< Principle << "\n";
	cout<< "Interest Rate is: "<<IR<< "\n";
	cout<< "Length of Loan is: "<<Years<<"\n";
	cout<< "Monthly Payment is: "<<MP<<"\n";
}

Check your function declaration. put only the data type

double CalcResults(double, double, double, double);

You didn't declare that WriteResults would be passing any parameters either. Declare it similar to CalcResults that I have there.

You have, at line 17, a variable called "WriteResults". This is the same name as one of your functions. What happens is that this local variable "hides" the global function (because identifiers of local scope hide any identifiers of larger scope that happen to have the same name). So, at lines 22 and 24, the compiler thinks that WriteResults refers to that local variable and not the global function, so it says that it "does not evaluate to a function .." because that local variable is not a function. So, since this variable is not used anyways, you should probably just take it out, or find a different name for it.

Also, you must have a perfect match between the function declarations (line 7 to 12) and the function definitions (lines 29, 39, 50, 60, 68 and 73) and that includes the correct function name (C++ is case-sensitive) (but not necessarily the same parameter names), the correct number of parameters, and the correct type for each of them (and correct result type too).

And I think your function calls (line 19 to 24) seem odd, you might want to double-check them (for instance, WriteResults has no return value (void) and yet you store that result in the variable results at line 22).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.