COP 1220 (C Programming) Project #1


Due: Wednesday, May 30, 2001, by the start of class

Purpose:

To practice basic C statements and programming ideas, such as if-statements, loops, and simple input and output.  To practice good programming techniques, style, design, testing, and good program documentation, on a small (about 70 lines of code) programming example.

Background:

A mortgage loan, or any loan, requires a schedule of payments.  Each payment represents some interest and some repayment of principal.  Although the amount of each payment is the same, the proportion of interest to principal changes for each payment in a complicated way.  It is very useful therefore to have a program that can calculate and print a schedule of loan payments.  (It is often a shock to discover how much interest will be paid, often more than double the amount of the loan!)

Programming Requirements:

In this project, we want to print a schedule of payments for a mortgage loan at a fixed rate of interest.  Although the method shown below is not the simplest, it will work and you must use it.  (Beside making the projects all based on the same formulas for easy and consistent grading, you get lots of practice working with formulas and converting them into C!)

Creative Points Hint:

A proper schedule useful to lawyers and accountants would print yearly subtotals for each calendar year.  Make sure not to print the totals twice if the last payment happens to be in December!

Use of pow() Function:

Calculating XY is easy with the pow() function.  The prototype for this function is: double pow (double X, double Y);
Sample use:  double z; z = pow(2.0, 3.0); /* now z equals 8.0 */
The arguments to pow can be arbitrary expressions.  Remember to include the <math.h> header file.

Sample Output:

A sample output is attached for a three year loan of $5000.00 at 8.0% annual interest which starts in August 1994.  Your output should look similar to this when your program is run using the test data provided below.  The output shows the prompt messages my program prints (with user input shown in boldface).  Then the actual output of the program is shown below that, which was redirected to the file loan.out.  This is the output that you need to print out and turn in (not the user prompts).

Note that the program was compiled as a DOS executable in order to use I/O redirection.  However this was not necessary since it is possible to save and/or print the output of a windows program.

Test Data:

You can (and should!) test your program with several different sets of data.  However, a printout of the following schedule must be turned in:

Amount:10000.00
Interest:8.5
Number of Payments:36
Starting Month:4
Starting Year:1998

To Be Turned In:

Ask me for help if you get stuck!

Sample run of program with output:

Sample Output




Send comments and mail to the WebMaster.