In: Computer Science
Need to create Mortgage Calculator Program In C++
Modify your mortgage to include two functions.
Test your program by getting the data from the user by using the first function and calculate monthly payment by calling the other function. Add version control and write proper comments with a few blank lines & indentations in order to improve your programming style.
#source code:
#include <math.h>
#include <iostream>
using namespace std;
void f1(); //function prototype for take user inputs
double f2(double,float,int); //function prototype for calculate monthly interest
void f1(void){ //function definition which is void type
double mortage;
float intrestRate;
int term;
//take user input
cout<<"Enter the mortage amount"<<endl;
cin>>mortage;
cout<<"Enter the intrest rate"<<endl;
cin>>intrestRate;
intrestRate=intrestRate/1200;
cout<<"Enter the term in years"<<endl;
cin>>term;
term=term*12;
cout<<"The calculated monthly payment is "<<f2(mortage,intrestRate,term)<<endl;
}
double f2(double mortage,float intrestRate,int term){ //function defintion for monthly interest
double monthlyPayment;
monthlyPayment=mortage*intrestRate/(1.0-pow(intrestRate+1,-term));
return monthlyPayment;
}
int main(){
f1(); //call the function
return 0;
}
#output:
#if you have any doubt or more information needed comment below..i will respond as possible as soon..thanks...