Hi, I could use some help. Our class assignment is to create a mortgage calculator in C++. The calcuation was provided all we had to do was code it. This is the fourth week of class and the assignment is from Ch. 2. I am sure it is not supposed to be as complicated as the codes that I have seen online.

Well, I have tried it. I have received one error that I do not know how to fix.

Thank you in advance.
alphabetanm

The error is error C2064: term does not evaluate to a function taking 1 arguments

which refers to my line (22) mPayment = (P*i)/q((1-pow((1 + (i/q)),-t))); //Formula to calculate mortgage payment amount

the whole coding is as follows:

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

using namespace std;

int main()
{
    double P = 100000; //Principle,initial amount of loan
    double i = .05; // the loan interest rate
    double n = 30; //lenght in years of the loan
    double q = 12; //number of payments per year
    double t = 30*12; //number of years * number of payments per year
    double mPayment; //monthly payment

    mPayment = (P*i)/q((1-pow((1 + (i/q)),-t))); //Formula to calculate mortgage payment amount

   cout << "\nPlease enter the principle.";  
   cin >> P;
   cout << "\nPlease enter the interest."; 
   cin >> i;
   cout << "\nPlease enter the years."; 
   cin >> t;


   return 0;
}

mPayment = (P*i)/q((1-pow((1 + (i/q)),-t)));

Didn't you forget to put a * after q?
By the way it gives back 323,406.

yes, I did forget.

Thank you for your help.

ab

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.