write a C++ application called calcMortgage for ABC Bank. The goal of this progr
ID: 3771378 • Letter: W
Question
write a C++ application called calcMortgage for ABC Bank. The goal of this program is to determine a monthly mortgage payment. calculating morgage as follows M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
M = monthly mortgage payment
P = the principal, or the initial amount you borrowed.
i = your monthly interest rate. Your lender likely lists interest rates as an annual figure, so you’ll need to divide by 12, for each month of the year. So, if your rate is 5%, then the monthly rate will look like this: 0.05/12 = 0.004167.
n = the number of payments, or the payment period in months. If you take out a 30-year fixed rate mortgage, this means: n = 30 years x 12 months per year, or 360 payments.
Explanation / Answer
#include <iostream>
#include <math.h>
using namespace std;
int main(){
int n;
double i,i_m,P,M;
cout<<"Emter Principal";
cin>>P;
cout<<"Enter rate of interest";
cin>>i;
i_m = i/1200;
cout<<"Number of months";
cin>>n;
M = P * (i_m * pow((i_m+1),n) / (pow((i_m+1),n)-1));
cout<<"Monthly mortage is "<<M;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.