Write a program to create an output file containing a customized loan amortizati
ID: 3673737 • Letter: W
Question
Write a program to create an output file containing a customized loan amortization table. Your program will prompt the usr to enter the amount borrowed (the principal), the annual interest rate, and the number of payments(n). To calculate the monthly payment, it will use the formula from Programming Project 1 in Chapter3. This payment must be rounded to the nearest cent. After the payment has been rounded to the nearest cent, the program will write to the output file n lines showing how the debt is paid off. Each month part of the payment is the monthly interest on the principal the rest is applied to thbalance, and e principal. Because the payment and each month's interest are rounded, the final payment will be a bit different and must be calculated as the sum of the final interest payment and the final principal balance. Here is a sample table for a $1,000 loan borrowed at a 9% annual interest rate and paid back over 6 months. Principal $1,000,000 payment $171.07, Annual interest 9.0% Term 6 months
Explanation / Answer
#include <stdio.h>
#include <math.h>
int main (void)
{
int Loan_Amount; // length of the loan
int Principle; // amount of the loan
float Interest;
float i, n, p;
float Payment;
printf("Please enter loan amount: ");
scanf("%d", &Principle);
printf(" Please enter annual interest rate: ");
scanf("%f", &Interest);
printf(" Please enter the number of payments: ");
scanf("%d", &Loan_Amount);
i = Interest/12;
n = Loan_Amount;
p = Principle;
while (Loan_Amount>0)
{
Payment = (i*p)/(1-pow((1+i),-n));
p = p - Payment + ((i/100)*p);
n = n-1;
printf (" Number of Payments: %d Amount per payment: %f ", Loan_Amount, Payment);
Loan_Amount = Loan_Amount - 1;
}
getchar ();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.