Design a class that will determine the monthly payment on a home mortgage. The m
ID: 3768045 • Letter: D
Question
Design a class that will determine the monthly payment on a home mortgage. The monthly payment with interest compounded monthly can be calculated as follows:
Payment = (Loan * Rate/12 * Term) / Term – 1
Where
Term = ( 1 + (Rate/12) ^ 12) * years
Payment = the monthly payment
Loan= the dollar amount of the loan
Rate= the annual interest rate
Years= the number of years of the loan
The class should have member functions for setting the loan amount, interest rate, and number of years of the loan. It should also have member functions for returning the monthly payment amount and the total amount paid to the bank at the end of the loan period. Implement the class in a complete program.
C++ Code please
Explanation / Answer
#include<iostream.h>
#include<conio.h>
#include<math.h>
class loan
{
public:
double Loan, Rate, years;
loan(double l, double r, double y)
{
Loan = l;
Rate=r;
years=y;
}
double month_ret()
{
double Payment,Term;
Term = ( 1 + pow((Rate/12), 12)) * years;
Payment = (Loan * Rate/12 * Term) / Term - 1;
return Payment;
}
};
void main()
{
double l,r,y;
cout<<"Enter Loan Amount";
cin>>l;
cout<<"Enter Interest Rate";
cin>>r;
cout<<"Enter Years";
cin>>y;
loan o(l,r,y);
double r1= o.month_ret();
cout<<"Monthly Payments is:"<<r1<<endl;
cout<<"Yearly Payments is:"<<(r1*12)<<endl;
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.