COSC 1315 - Fundamentals of Programming
Allan Kochis

Programming Assignment 2


How do you calculate your monthly payment for a monthly mortgage or car loan?
You need to know three things.
  1. The principle, how much are you borrowing? We will call this P
  2. The annual interest rate called I, expressed as 13 for 13%.
  3. The number of years to repay the loan. L

Since we will be working with months, we must convert our yearly figures to monthly.

  1. The number of months to repay the loan N=L * 12
  2. The monthly interest J=I/(12*100)

Then to compute M the monthly payment

The equation is:

Write an IPO that will read in the three required values, P,I, and L and compute and print out M the monthly payment.
Example:

Payment Calculator
How much are you borrowing ? : 2000

What is the annual interest rate?
  example for 13 1/2% enter 13.5
  Rate : 12

 How many years for this loan?
   example for 42 months enter 3.5
   Years : 2

The Payment is : 94.147