Due date: Thursday, April 8, 2004.
Ex. 1 Write a program that computes the number of months that a necessary to reimburse a loan and the last payment based on the yearly rate of interest and on the monthly payment. The program should input the amount of the loan, the monthly payment and the yearly rate, and it should output the number of months and the last payment.
The program must contain a function with the following prototype:
void ComputePayment(float total, float monthly, float rate, int &months, float &last_payment);
The prototype of the function must appear before the main, and the function should be implemented after the main. The main should input the data, call this function, and then output the results.
To compute the number of months, consider that the amount due after 1 month of payment is
total*(1+rate/12) - monthly
In the computation function, you must have a loop that goes on while the amount due is greater than 0, and you must count the number of iterations to find the number of months. When the sum has become <= 0, the last payment will be the monthly rate plus that negative (or 0) total amount due in the end.
Send me: Source code file containing an example of program execution.