Answered step by step
Verified Expert Solution
Link Copied!

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 inC++ : 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, 14 percent can cost significantly less than 14 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 and/or months). As an example, for $20,000 loan with 10% APR for duration of 2 years:
P =20000(dollars and cents)
APR =10(percentage)
n =24(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:
M=Pr(1+r)n(1+r)n-1
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, i.e., 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 12 would not produce an accurate rate of interest per month. The exact formula for the monthly interest would require taking the 12th root of annual interest as follows:
r=(1+APR100)12-1
On a loan of $20,000, with 10% APR:
r =0.007974
Therefore:
M = $918.92
This monthly payment of $918.92 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 1, interest would be P*r = $159.48, and the remaining $759.44 would decrease the balance to $19240.56.
Month 1
Payment = $918.92 Interest = $159.48 principal = $759.44 Balance =19,240.56
For month 2, interest would be paid on the remaining balances as r * $19,240.56.
Month 2
Payment = $918.92 Interest = $153.43 principal = $765.50 Balance =18,475.06
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 $918.92
Total Payments $22,054.19
Total Interest $2,054.19
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 call-by-value function.
- A function that calculates and returns amortization, M using inputs of P, r, and n. This can be a call-by value function.
- A function that calculates the interest and principal balance for every month. This can be a call-by reference function.
- A function that keeps track of total payment and total interest accumulated. This can be a call-by-reference 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 call-by-reference function.
- An output function which displays the summary of payments at the end. This can be a call-by-reference function.
Note: To create tabular data, use the \t for equally spaced data. Alternatively, use thecout.width(4) to create equal length data fields (4 is just an example).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Why did Hostess Brands Inc. go into bankruptcy?

Answered: 1 week ago