CS 1044, Schuetz
Programming Assignment #2
Spring 1998

Due Date: 11:59 pm, Tuesday, February 17, 1998.

No Cooperative Work Allowed: Programming assignment 2 must be entirely your own work. Assistance should only be sought or accepted from the course GTA's, the course instructor, or the Computer Science paid consultants on duty in the evening in McBryde 116.

Objectives: This assignment will give you the opportunity to 1) design and write your first C++ program, 2) use the repetition construct while, 3) use the selection construct if . . . else, 4) practice using file streams and formatting output, and 5) use the four basic arithmetic operations of addition, subtraction, multiplication, and division.

Problem Statement:

uppose you take out a loan of $1,000 at a yearly interest rate of 12% and you intend to repay that loan at $200 (including the interest payment) per month until the loan has been fully repaid. You would like to have an amortization schedule showing the following entries: the interest charge, the payment towards the loan, the remaining balance, and the accumulated interest to date. One way to solve this problem is shown here (the monthly interest rate is 1% since the yearly rate is 12%, i.e., 12%/12 months = 1% per month):
	The interest for month 1 is	$1000  *  0.01	=  $ 10.00
	The payment to capital is 	$200  -  10	= $190.00
	The remaining balance is 	$1000  -  190	= $810.00
	
	The interest for month 2 is	$810  *  0.01	=  $   8.10
	The payment to capital is 	$200  -  8.10	= $191.90
	The remaining balance is 	$810  -  191.90	= $618.10
You are to write a program to read an arbitrary loan amount, a monthly repayment amount, and a yearly interest rate and produce a repayment schedule formatted like the one shown under output below.

Input: The input will be a single line which your program should read from a file called "asgn2.in". The line will contain three numbers: the first will be the amount of the loan (real), the second will be the monthly repayment amount (integer), and the third will be the yearly interest rate (real, in decimal form, e.g., 0.115 signifies 11.5% per year). Assume all three data items are valid.

Output: Your program should create and send output to a file named "asgn2.out". Your output should have the exact form illustrated below. It has one blank line between the three-line title and the column headers and all words are in upper case. Failure to follow this form exactly will result in the automated grader deducting points. In the title, the X's after PRINCIPAL should be replaced with the principal value read from the input file, the Y's by the interest rate input, and the Z's by the input amount of the monthly payments.

                                 AMORTIZATION TABLE
                      PRINCIPAL  $XXXX.XX        INTEREST  YY.YY
                               REGULAR PAYMENT  $ZZZ

	NO.	INTEREST	AMORTIZED		BALANCE	INTEREST TO DATE
	  1	  10.00	 	  190.00	  	  810.00	  10.00
	  2	    8.10	  191.90		  618.10	  18.10
	  3	    6.18	  193.82		  424.28	  24.28
	  4	    4.24	  195.76		  228.52	  28.52
	  5	    2.29	  197.71		   30.81	  30.81
	  6	    0.31	   30.81		    0.00	  31.12

Documentation: Your program should include all the documentation called for in the "Elements of Programming Style." This document appears as an appendix in the printed class notes and is also accessible on the WWW from the course home page. Particularly applicable to this program are sections 1, 2, 3, 5, 6, and 7. Your header documentation should have the appearance of the example header in section 3. You can omit the two items labeled USAGE and COMPILE, but you should include two items describing the input and output of the project. Check your first programming project about calculating employee pay for an example of how to describe the input and output of a program. Documentation is important and is a required part of evry programming assignment.

Submission: You should submit your source code electronically to the automated grader. As with the first programming project, you will be allowed a maximum of four submits.