Answer :
Final answer:
To design a class for mortgage payment calculation, you need to consider the loan amount, interest rate, and number of years of the loan. The monthly payment can be calculated using the formula: Monthly Payment = (Loan Amount * Monthly Interest Rate) / (1 - (1 + Monthly Interest Rate)^(-Number of Months)). Implement the class with member functions for setting the loan amount, interest rate, and loan duration, as well as returning the monthly payment amount and the total amount paid to the bank at the end of the loan period. Include input validation to ensure only numbers are accepted and the program exits if the loan amount is less than 0. Ask the user if they want to calculate another mortgage amount and exit the program if they enter anything other than 'Y' or 'y'.
Explanation:
To design a class for mortgage payment calculation, we need to consider the loan amount, interest rate, and number of years of the loan. The monthly payment with interest compounded monthly can be calculated using the following formula:
Monthly Payment = (Loan Amount * Monthly Interest Rate) / (1 - (1 + Monthly Interest Rate)^(-Number of Months))
To implement the class, we can create member functions for setting the loan amount, interest rate, and loan duration. We can also create member functions for returning the monthly payment amount and the total amount paid to the bank at the end of the loan period. Additionally, we need to include input validation to ensure that only numbers are accepted and the program exits if the loan amount is less than 0. After calculating and printing out the mortgage information, we can ask the user if they want to calculate another mortgage amount and exit the program if they enter anything other than 'Y' or 'y'.
Learn more about designing a class for mortgage payment calculation here:
https://brainly.com/question/34896385
#SPJ14