CSc 330 – Object-Oriented Programming & Design – Professor Domanski

Lab 1 – Simple Loan Calculator

 

All programs must have your name, and lab number on them; in additions, all programs must be commented (you don't have to go crazy, but the comments should explain enough so that someone who doesn't know the program can follow the general flow of the program).  Your program will not be handed in; you will present / demonstrate it in front of the class when it’s due.  Be prepared to explain your code, and why you did what you did.

 

Lab 1 – Given 3 of the 4 items of data, compute and display the missing piece.

 

 

How?  Using the formulas below:

 

Scenario #1: Find the Monthly Payment

Loan Amount (C) =
Interest Rate % (R) =
Number of Months (N) =
Monthly Payment (P) = ?   

Interest rate R% is always a yearly figure. However, in most loan situations it is compounded monthly. In this calculator the monthly payment is calculated by the following formula where r = R/1200:

 

 


 

Scenario #2: Find the Interest Rate

Loan Amount (C) =
Monthly Payment (P) =
Number of Months (N) =
Interest Rate % (R) = ?   

For given C, P and N, one can only solve the following equation for r by numerical means.

Given the rather smooth behavior of this equation, this calculator employs the Newton-Raphson method with an educated initial guess:

.

Keep calculating new guesses from old using this formula –

 

 

- until the difference between a new guess and an old guess is less than .0001

 

 

Scenario #3: Find the Number of Payments

Loan Amount (C) =
Interest Rate % (R) =
Monthly Payment (P) =
Number of Months (N) = ?   

This calculator figures out the number of months N by the following closed-form expression:

 

 

 

What You Need To Know - How to do math in C++; how to set up a GUI

 

Due – Tue 9/18