Skip to main content
Lesson 10 - for, do-while, Nested Loops
Lesson MenuPreviousNext
  
L.A.10.2 - Payments page 9 of 10

Background:

Borrowing money for expensive items has become a way of life for most Americans. To illustrate the high cost of borrowing and how such loans work, you will write a program to calculate the following monthly analysis of a loan.

Month     Principal     Interest        Payment   New Balance
        
  1        10000.00       100.00         300.00       9800.00
  2         9800.00        98.00         300.00       9598.00
  3         9598.00        95.98         300.00       9393.98
  4         9393.98        93.94         300.00       9187.92
and many months later ...
 39          809.46         8.09         300.00       517.55
 40          517.55         5.18         300.00       222.73
        
                         2222.73  total interest

The loan analysis above started with the following information:

Principal (amount borrowed)     = 10000.00
Annual interest rate            = 12.0 %
Monthly payment                 = 300.00

The monthly interest rate is found by dividing the annual rate among 12 months. For the above example the monthly rate is 1.0 %. The last three values of each line are calculated as follows:

Interest = Principal * Monthly interest rate
Payment = amount set at beginning of problem
New Balance = Principal + Interest - Payment

The new balance becomes the starting principal amount for the next month. As you can see, progress toward decreasing the principal is slow at the beginning of the loan.


Assignment:

Write a program to analyze a loan as described above using the five column format. Your program must accomplish the following:

  1. Data input: The program should ask for the appropriate starting information.

  2. Printing of analysis: The program must print the month-by-month analysis until the remaining principal is less than the monthly payment. You must use a do-while loop to solve this problem. At the bottom of the analysis you must print the total interest paid to the lending institution.


Instructions:

  1. After completing your program, test it using the data given in the example. Your answers should agree within a few cents.

  2. You are to analyze the following loan data:

    principal = 12000
    annual interest rate = 8.80
    monthly payment = 500.00
  3. Turn in your source code and run output.


Extending the Lab:

  1. We now reverse the idea. Suppose we wish to study the effect of time and compounding interest on investments. Revise the program to ask the user for:

    starting principal to invest
    annual rate of return (5%, 10%, etc)
    monthly addition to the principal
    number of months to iterate
  2. The printout will be similar except the column called "payment" will be changed to investment. You should still calculate and print out the total interest and final balance.

  3. This lab exercise should encourage you to start investing early in life.


Lesson MenuPreviousNext
Contact
 ©ICT 2003, All Rights Reserved.