Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: Functions, math and file stream modules, fundamental programming and problem solving Loan Calculator: Interest on a loan is paid on a declining balance, and

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Objective: Functions, math and file stream modules, fundamental programming and problem solving Loan Calculator: 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. Write a program that takes a loan amount and interest rate as input and then outputs the monthly payments and balance of the loan until the loan is paid off. Typically, the monthly payments are calculated using the amortization equation as follows: M=P(1+r)n1r(1+r)n Where: M= monthly payments M=? P= the principal loan amount P=20000$20000loandesired r= monthly interest rate (annual interest rate / 12) For 10% interest rate variable r would be 0.1/12 per month >r0.0083333 n= number of payments over loan's lifetime in months (e.g., loan years * 12) 2 years loan 12 is 24 month >n=24 Any monthly payment amount more than the interest is credited toward decreasing the balance due. On a loan of $20,000, the payments would be fixed at $922.90 a month. M=$922.90 Assuming an interest rate of 10 percent, then each month the interest accounts for portion of the monthly payment and the remaining portion of the payment would go towards the balance owing. The first month, ( 10 percent of $20,000)/12, or $166.67, would be paid in interest, and the remaining $756.23 would decrease the balance to $19,243.77. Month 1 Payment=$922.90Interest=$166.67principal=$756.23Balance=19,234.77 For month 2 , the interest would be (10 percent of $19,234.77)/12, and the program continues till the 24 month is over. Your program should output to a file as well display on the screen a table that shows the interest and principal portion of the loan for every month as well as the total interest paid up to that month and the remaining balance. Finally the program output the total interest paid over the life of the loan like follows: Payment Every Month $922.90 Total of 24 Payments $22,149.56 Total Interest $2,149.56 Your program should allow the user to repeat this calculation as often as desired. Amortization Schedule \begin{tabular}{|r|r|r|r|r|} \hline & Beginning Balance & Interest & Principal & Ending Balance \\ \hline 1 & $20,000.00 & $166.67 & $756.23 & $19,243.77 \\ \hline 2 & $19,243.77 & $160.36 & $762.53 & $18,481.23 \\ \hline 3 & $18,481.23 & $154.01 & $768.89 & $17,712.35 \\ \hline 4 & $17,712.35 & $147.60 & $775.30 & $16,937.05 \\ \hline 5 & $16,937.05 & $141.14 & $781.76 & $16,155.29 \\ \hline 6 & $16,155.29 & $134.63 & $788.27 & $15,367.02 \\ \hline 7 & $15,367.02 & $128.06 & $794.84 & $14,572.18 \\ \hline 8 & $14,572.18 & $121.43 & $801.46 & $13,770.72 \\ \hline 9 & $13,770.72 & $114.76 & $808.14 & $12,962.58 \\ \hline 10 & $12,962.58 & $108.02 & $814.88 & $12,147.70 \\ \hline 11 & $12,147.70 & $101.23 & $821.67 & $11,326.03 \\ \hline 12 & $11,326.03 & $94.38 & $828.51 & $10,497.52 \\ \hline 13 & & Year #1 End & & \\ \hline 14 & $10,497.52 & $87.48 & $835.42 & $9,662.10 \\ \hline 15 & $9,662.10 & $80.52 & $842.38 & $8,819.72 \\ \hline 16 & $8,819.72 & $73.50 & $849.40 & $7,970.32 \\ \hline 17 & $7,970.32 & $66.42 & $856.48 & $7,113.84 \\ \hline 18 & $7,113.84 & $59.28 & $863.62 & $6,250.22 \\ \hline 19 & $6,250.22 & $52.09 & $870.81 & $5,379.41 \\ \hline 20 & $5,379.41 & $44.83 & $878.07 & $4,501.34 \\ \hline 21 & $4,501.34 & $37.51 & $885.39 & $3,615.95 \\ \hline 22 & $3,615.95 & $30.13 & $892.77 & $2,723.18 \\ \hline 23 & $2,723.18 & $22.69 & $900.21 & $1,822.98 \\ \hline 24 & $1,822.98 & $15.19 & $907.71 & $915.27 \\ \hline & $915.27 & $7.63 & $915.27 & $0.00 \\ \hline \end{tabular} - An output function which displays the table to the screen and writes it to a file

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

Step: 3

blur-text-image

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

The Power Of Numbers In Health Care A Students Journey In Data Analysis

Authors: Kaiden

1st Edition

8119747887, 978-8119747887

More Books

Students also viewed these Databases questions