Programming Assignment 11
Write a C++ program
to compute the monthly and total payments for a bank loan. Your program should do the following:
1. Read
in the amount of the loan (amount),
duration of the loan in months (months),
and the interest rate (rate).
2. Calculate
expm (compound interest factor), which is defined by
expm
= (1 + rate/12)months
3. Calculate
monthly_payment which is defined
by
monthly_payment = (rate / 12) * expm *
amount / (expm - 1)
4. Calculate
total_payment which is the defined
by
total_payment
= monthly_payment * months
Your program should
read in amount, months, and rate until a
sentinel value of 0 is found for the amount.
Your program should
have two functions (in addition to main). The first function Expm should be used to calculate expm. The second function M_Pay should be used to calculate monthly_payment. Use C++'s pow function to compute the power.
Your output should
look like the following:
AMOUNT
MONTHS RATE MONTHLY PAYMENT TOTAL PAYMENT
10000.00 36 9%
318.00 11447.90
XXXXX.XX XX XX%
XXXX.XX XXXXXX.XX
etc.
etc. etc. etc. etc.
Use the following input
data for your program.
AMOUNT
MONTHS RATE
10,000
36 .09
10,000
48 .09
10,000
36 .10
10,000
48 .10
20,000
36 .10
20,000
48 .10
0 0 .00
Note: C++'s pow
function is prototyped in cmath. The prototype is
double
pow(double x, double n); and the
function returns xn.
Make sure your program works correctly.