Very early on, computer programs were recognized for their ability to compute tedious financial and accounting records. The purpose of this assignment is to produce an amortization table for a loan. Amortization tables are used to calculate a monthly payment on a loan as well as details on each monthly payment (principle remaining, amount to interest, amount to principle, etc.).
principle = the total amount of money left to be paid on the loan
interest rate = the monthly rate at which interest is added to the principle
period = the total number of months allowed for paying off the loan
monthly payment = the minimum amount required to pay off the principle and interest per month
additional payment = any amount of money paid above the minimum monthly payment
This program will use several methods as outlined below. The program will prompt the user for the principle, interest rate, period, and any additional payment amounts. The monthly payment will be calculated by a calling a function. For each month in the period, a line will be added to the output that includes relevant variables. The last monthly payment may be off by a very small amount. Your program should ensure that the remaining balance is exactly zero.
To calculate the monthly payment, use the following formula:
monthlyPayment = ( interestRate + (interestRate / ( ( 1 + interest rate ) ^ period - 1 ) ) ) * principle
NOTE: students with correct solutions to Mini-Project-2 are encouraged to reuse their solutions in this program.
The following variables must be prompted and typed into the keyboard.
double principle = initial loan amount
double interestRate = monthly interest rate (yearly rate/12.0)
int period = number of months
double additionalPayment = amount of extra payment per month a shrewd borrower will add to the monthly payment
Your program will produce an output file, named amortizationTable.txt, which contains the eight variables. The file must be formatted with values up to $100,000.00. All values must have a precision of two decimal places. The following is a rough example of the variables to display and does NOT conform to the output requirements:
The input variables are prompted by the user. Your program must process the inputs and produce the entire correct amortization file to receive credit. Name your program by last name, first initial, and project-4. Thus, for Jonathan Leidig, the file name would be Leidig-J-Project-4.cpp. You only need to submit your .cpp file and it does not need to be placed in a zip file. The hardcopy turned into class will be worth 30% of the grade and the correctness of the Curator copy with a set of inputs will be 70% of the grade.
The following is a rough outline for the structure of the project. You may restructure the program as desired.
double calculateMonthlyPayment(double myPrinciple, double myInterestRate, int myPeriod);
//Note: the monthly interest rate 1% should be entered as 0.01
double principle, interestRate, additionalPayment, monthlyPayment;
//Open output file amortizationTable.txt
//cin initial values for principle, interestRate, additionalPayment, period
//Calculate the monthlyPayment separate from any additional payments
monthlyPayment = calculateMonthlyPayment(principle, interestRate, period);
//write the file header
//month principleRemaining monthlyPayment amountToPrinciple amountToInterest totalPaid totalPrinciplePaid totalInterestPaid
double principleRemaining=0, amountToPrinciple=0;
double amountToInterest=0, totalPaid=0, totalPrinciplePaid=0, totalInterestPaid=0;
//process each month, month == i
for( int i = 0; i < period && principleRemaining > 0; i++)
//Interest is charged each month. The following expressions show how to calculate each value.
amountToInterest = principle * interestRate per month
amountToPrinciple = monthlyPayment - amountToInterest + additionalPayments
principleRemaining -= amountToPrinciple
totalPaid += amountToPrinciple + amountToInterest
totalInterestPaid += amountToInterest
totalPrinciplePaid += amountToPrinciple
write( i + \t + principleRemaining + \t + monthlyPayment + \t + amountToPrinciple
+ \t + amountToInterest + \t + totalPaid + \t + totalPrinciplePaid + \t + totalInterestPaid)
double calculateMonthlyPayment(double myPrinciple, double myInterestRate, int myPeriod)
double myMonthlyPayment = 0;