0% found this document useful (0 votes)
16 views

C++ - Mortgage Payment Calculation Program - CPP

Uploaded by

soat
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

C++ - Mortgage Payment Calculation Program - CPP

Uploaded by

soat
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <cstdio>

#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
class Mortgage
{
public:
Mortgage (float fAb, float fYI, int nYEARS)
: fAborrowed(fAb), fYint(fYI), nyears(nYEARS)
{}
float PMT ()
{ float fMint=(fYint/(12*100));
// A = D[i(1 + i)^n]/[(1 + i)^n - 1]
one_plus_i_to_n = pow( (1+fMint), (nyears*12) );
fPAmount = fAborrowed * (fMint * one_plus_i_to_n) /
(one_plus_i_to_n -1);
return (fPAmount);
}
private:
float fMint;
float fPAmount;
float fAborrowed;
float fYint;
float one_plus_i_to_n;
int nNM;
int nyears;
};

int main ()
{
float Principal =0;
float Yint=0;
int nY=0;
float Payment;
cout << "Enter Principal " << endl;
cin >> Principal;
cout << "Enter Yearly Interest Rate " << endl;
cin >> Yint;
cout << "Enter number of years " << endl;
cin >> nY;
Mortgage M (Principal, Yint, nY);
Payment=M.PMT();
cout << "Mortgage Payment --> " << M.PMT() << endl;
return 0;
}

You might also like