Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write this program i n C + + : A loan calculator will help you determine your monthly payments if you decide to borrow
Please write this program : A loan calculator will help you determine your monthly payments if you decide to borrow moneyin the form of student loans, car loans and renovation loans. You would be creating your very own and fully accurate loan calculator for this assignment.
The good news is that interest on a loan is paid on a declining balance, and hence a loan with an interest rate of say, percent can cost significantly less than percent of the balance if paid
within a year.
Write a program that takes as input the loan amount P annual percentage rate APR and the loan term in years andor months As an example, for $ loan with APR for duration of years:
P dollars and cents
APR percentage
n months
The program calculates and displays the monthly payments and balance of the loan until the loan is paid off. This is known as amortization schedule
Steps to Solve the problem:
To solve this problem, you would need to figure out the monthly fixed payments first. Typically, the monthly payments are calculated using the amortization equation as follows:
Where M is the monthly payments, P is the principal loan amount, r is the monthly interest rate and n is the number of payments over loans lifetime.
The first step would be conversion of the APR to r ie the annual percentage rate of interest to monthly rate of interest. The loan interest per month is slightly less than one twelfth of the interest loan per year. So simply dividing the annual interest by would not produce an accurate rate of interest per month. The exact formula for the monthly interest would require taking the th root of annual interest as follows:
On a loan of $ with APR:
r
Therefore:
M $
This monthly payment of $ covers both the balance owed, and the interest accumulated.
Therefore, the interest accounts for a portion of the monthly payment and the remaining portion of the payment would go towards the principal.
Monthly Payment Interest Principal
For month interest would be Pr $ and the remaining $ would decrease the balance to $
Month
Payment $ Interest $ principal $ Balance
For month interest would be paid on the remaining balances as r $
Month
Payment $ Interest $ principal $ Balance
The program iterates over the term of the loan till the balance is zero.
Your program should display a table like above that shows the interest and principal portion of the loan for every month as well as the remaining balance.
In addition, the program should output the total interest paid over the life of the loan like follows:
Payment Every Month $
Total Payments $
Total Interest $
Your program should allow the user to repeat this calculation as often as desired until done.
Functions that are needed to run the program
A function that calculates and returns monthly interest rate r using the APR as input argument. This can be a callbyvalue function.
A function that calculates and returns amortization, M using inputs of P r and n This can be a callby value function.
A function that calculates the interest and principal balance for every month. This can be a callby reference function.
A function that keeps track of total payment and total interest accumulated. This can be a callbyreference function.
An input function which prompts and fills the input with values for P APR, and n This is a call by reference function.
An output function which displays tabular information. This can be a callbyreference function.
An output function which displays the summary of payments at the end. This can be a callbyreference function.
Note: To create tabular data, use the t for equally spaced data. Alternatively, use thecout.width to create equal length data fields is just an example
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started