Hello, Need help whith this program,there are two parts.So please do both .Pleas
ID: 3554816 • Letter: H
Question
Hello,
Need help whith this program,there are two parts.So please do both .Please add comments to all main operation so I can follow it clearly.Please create variables and not do the calculation in the cout statement .
Write a C++ program to help a prospective borrower calculate the monthly payment for a loan. The program also prints the amortization (payoff) table to show the balance of the loan after each monthly payment. I he program prompts the user to input the following: The program then creates an information summery and amortization table. Use the following formula to calculate the monthly payment of a loan. //NM: number of months to amortize loan // NY: number years to amortize loan //IM: interest rate /month (decimal) //IY: interest rate per year (percentage) //P: the value of (1 + IM)NM //Q: the value of ( P / (P -1)) // MP: monthly payment (rounded to two decimal places) // PR is the principal or the loan amount A sample output format (information and table) for the above input is shown below The main functions must call three other functions: calcMonthlyPayment printlnformation print AmortizationTableExplanation / Answer
#include <iostream>
#include <math.h>
using namespace std;
float calcMonthlyPayment(float PR,float IY,int NY){
float IM, P, Q, MP;
int NM;
NM = NY * 12;
IM = (IY/12.0)/100.0;
P = pow(1+IM, NM);
Q = P/(P-1);
MP = (PR*IM*Q);
return MP;
}
void printInformation(float MP,float PR,float IY,int NY){
float IM = IY/12.0;
int NM = NY*12;
cout<< "Loan Amount: "<<PR<<endl;
cout<< "Interest Rate per month (IM) : "<<IM<<endl;
cout<< "Number of months (NM) "<<NM<<endl;
cout<< "Monthly Payment is: "<<MP<<endl;
}
void printAutomizationTable(float MP,float PR,float IY,int NY){
float IP, PP, Bal;
float IM = IY/12;
int NM = NY*12;
cout<<"Month Old Balance Monthly Payment Interest Paid Principal Paid NewBalance"<<endl;
for (int i = 1; i <= NM; i++){
IP = PR*IM/100;
PP = MP-IP;
Bal = PR-PP;
cout<<i<<" "<<PR<<" "<<MP<<" "<<IP<<" "<<PP<<" "<<Bal<<endl;
PR = Bal;
}
}
int main(){
float PR, IY, MP;
int NY;
cout<<"Loan Amount (principal) : ";
cin>>PR;
cout<<"Interest rate per year (percent) ";
cin>>IY;
cout<<"Number of Years? ";
cin>>NY;
MP = calcMonthlyPayment(PR,IY,NY);
printInformation(MP, PR, IY, NY);
printAutomizationTable(MP, PR, IY, NY);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.