In: Computer Science
Write a program that utilizes a function called paymentCalc. In the main body of the program, ask the user what is their principal and how many months they want the loan. If it is easier, ask the user for number of years, but don’t forget to change it to months for the calculation. Use a function to calculate their monthly mortgage payment. In the main body of the program, print out what their monthly mortgage payment will be. For simplicity, let’s make the monthly interest rate .007
in c++
#include<iostream>
using namespace std;
const float rate=0.007;
float paymentCalc(float a,float y)
{
float m=y*12;
float i=a*m*rate;
float p=i/m;
return p;
}
int main()
{
float yr,amount;
float pay;
cout<<"\nEnter the principal amount :";
cin>>amount;
cout<<"\nEnter the time period in years :";
cin>>yr;
pay=paymentCalc(amount,yr);
cout<<"\nMonthly payment :\n"<<pay;
}
If you have any questions comment down. Please don't simply downvote and leave. If you are satisfied with answer, please? upvote thanks