Loan Payment Table

Computer Methods in Chemical Engineering


Problem Statement: The follwing formula relates payment per period, interest rate, and principal of a loan/annuity.

  payment = P * r / (1-1/(1+r)N)
  where  payment = equal monthly payment
         P       = original principal
         r       = interest rate per payment period
         N       = number of payment period
Suppose you obtain from a bank a 3-year loan of $12,000 to purchase a car at an annual percentage rate (APR) of 9%. The loan is to be paid back in equal monthly installments. Write a program to find the equal monthly payment, the total interest and principal payments, and print out a repayment table resembling the following.
  -------------------------------------------------------
  Month   Interest-Paid  Principal-Paid        Balance
   -------------------------------------------------------
     0            0.00            0.00        12000.00
     1           90.00          291.60        11708.43
     :             :               :               :
    36            2.84          378.63            0.00
  -------------------------------------------------------
  Total       13737.47        12000.00            0.00
Extra Credits Only. Since, $0.01 is the lowest US currency denomination and you cannot transact a fraction of a penny in practice, add steps to round off the monthly payment to the nearest penny. Because of the round-off, the last payment is usually different from the rest by a few pennies to make the last balance come out to 0. Note: Mathcad v5.0 provides a function "floor(x)" to truncate a real number x and "ceil(x)" to push up a real number x to the next integer. (e.g., floor(3.3)=3 & ceil(3.3)=4). In addition, Mathcad provides a modulus (remainder) function "mod(x,y)" (e.g., mod(5,3)=2). You may find these inter-related functions to be useful in defining a round-off function "round(x)".

Solution:


Problem Statement: Solve the above problem (the monthly payment problem). Specifically, you should write a function that returns the balance at the end of specified number of payment periods. Allow both positive and negative balances. You should provide a main program that read/set the original principal, annual interest rate, and the number of monthly payments to be made. Call a subroutine that solves an equation of the form f(x)=0 to find the fixed, equal monthly payment. After you find the monthly payment, print out a table of payment schedule.

Test case: You will find this program to be very useful in managing your personal finance. You test the program with the tuition loan from the last quiz or any type of loan (car loan or home mortgage). Suppose you obtain from a bank a 3-year loan of $12,000 to purchase a car at an annual percentage rate (APR) of 9%. The loan is to be paid back in equal monthly installments. Write a program to find the equal monthly payment, the total interest and principal payments, and print out a repayment table resembling the following.

  -------------------------------------------------------
  Month   Interest-Paid  Principal-Paid        Balance
   -------------------------------------------------------
     0            0.00            0.00        12000.00
     1           90.00          291.60        11708.43
     :             :               :               :
    36            2.84          378.63            0.00
  -------------------------------------------------------
  Total       13737.47        12000.00            0.00
There exists a "fancy" formula to calculate the monthly payment, but I do not want you to use it because I want you to practice putting a given problem in the standard "f(x)=0" form. The "fancy" formula you will learn in ENCH444 (Process Engineering Economics and Design), which you might want to use as an analytical reference to check your numerical result, is:
  payment = P * r / (1-1/(1+r)N)
  where  payment = equal monthly payment
         P       = original principal
         r       = interest rate per payment period
         N       = number of payment periods

Extra Credits Only. Since, $0.01 is the lowest US currency denomination and you cannot transact a fraction of a penny in practice, add steps to round off the monthly payment to the nearest penny. Because of the round-off, the very last payment is usually different from the rest by a few pennies to make the last balance come out to exactly 0. Furthermore, since you get only ~7 significant digits with the regular, single precision real variable in FORTRAN, a program written in single precision may miss a few pennies when the loan amount is, say $1,000,000.00. Since you may one day be able to afford a million dollar house; you may want to write your program in double precision real variables to handle accurately a large number.

Solution:


Return to Prof. Nam Sun Wang's Home Page
Return to Computer Methods in Chemical Engineering (ENCH250)

Computer Methods in Chemical Engineering -- Loan Payment Table
Forward comments to:
Nam Sun Wang
Department of Chemical & Biomolecular Engineering
University of Maryland
College Park, MD 20742-2111
301-405-1910 (voice)
301-314-9126 (FAX)
e-mail: nsw@umd.edu ©1996-2006 by Nam Sun Wang
UMCP logo