Question: (5.) This program must be written in C++: The purpose of this lab is to practice working with basic classes. ______________________________________________________________________________ Design a class Mortgage
(5.) This program must be written in C++: The purpose of this lab is to practice working with basic classes. ______________________________________________________________________________ Design a class Mortgage that is used to determine the monthly payment on a home mortgage. The class should contain at least the following private attributes: loanAmount: the dollar amount of the loan rate: the annual interest rate years: the number of years of the loan. The class should have a default constructor as well as other public member functions to: set the loan amount, interest rate, and number of years of the loan display the loan amount, interest rate, and number of years of the loan compute the monthly payment amount and total amount paid to the bank at the end of the loan period. The monthly payment, monthlyPay, with interest compounded monthly can be calculated as follows: monthlyPay = (loanAmount * term * rate/12) / (term -1) Where term = (1 + rate/12) 12*years compute the total amount paid to the bank by the end of the loan period Your main program should ask the user for the loan information and display the monthly payment and total amount paid by the end of the loan period. A sample output is shown below: Enter the loan amount in dollars: 500000 Enter the annual interest rate in decimal form: 0.0275 Enter the length of the loan in years: 30 Monthly payment: $2041.21 Total payback: $734834.13 Note: You must separate your files into .cpp and .h file. Input validation: you should do not accept negative numbers for any of the loan values
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
