C Programming Write a Program to create a table containing a customized loan amo
ID: 669732 • Letter: C
Question
C Programming
Write a Program to create a table containing a customized loan amortization table. Your program will prompt the user to enter the amount borrowed (the principal), the annual interest rate(format: 5.05 is 5.5%), and the number of monthly payments (n). To calculate the monthly payment, use the following formula:
where
• P is the initial principal amount
• i is the monthly interest rate ( 1/12 of the APR)
• n is the total number of payments(payment periods)
Note that this payment must be rounded to the nearest cent. After the payment has been rounded to the nearest cent, the program will create a table that looks like the following
Principal: 1000.00
Annual Interest Rate: 9.00
Term in month: 6
Monthly Payment: $171.07
Payment Interest Principal Balance
1 $7.50 $163.57 $836.43
2 $6.27 $164.80 $671.63
3 $5.04 $166.03 $505.60
4 $3.79 $167.28 $338.32
5 $2.54 $168.53 $169.79
6 $1.27 $169.79 $0.00
Final Payment : $171.06
Each month, part of the payment is applied to the interest and the rest is applied to the principal Because the payment and each month’s interest rate 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.
Explanation / Answer
#include <stdio.h>
#include <math.h>
int main (void)
{
int num_payments; // length of the loan
int Principle; // amount of the loan
float InterestRate;
float i, n, p;
float PaymentAmount;
printf("Please enter loan amount: ");
scanf("%d", &Principle);
printf(" Please enter annual interest rate: ");
scanf("%f", &InterestRate);
printf(" Please enter the number of payments: ");
scanf("%d", &num_payments);
i = InterestRate/12;
n = num_payments;
p = Principle;
while (num_payments>0)
{
PaymentAmount = (i*p)/(1-pow((1+i),-n));
p = p - PaymentAmount + ((i/100)*p);
n = n-1;
printf (" Number of Payments: %d Amount per payment: %f ", num_payments, PaymentAmount);
num_payments = num_payments - 1;
}
getchar ();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.