Write a C program named loanCalc.c that calculates monthly payment and print a t
ID: 3937060 • Letter: W
Question
Write a C program named loanCalc.c that calculates monthly payment and print a table of payment schedule for a fixed rate loan, which performs a similar task as in the link below: http://www. bankrate.com/calculators/mortgages/loan-calculator.aspx In this C program, the input and output are defined as following: bullet Input: amount of loan, interest rate per year and number of payments bullet Output: a table of amortization schedule (also called payment schedule) containing payment number, monthly payment, principal paid, interest paid and new balance at each row. The attached screenshot below shows a sample of the output. Yuans-MacBook-Pro:PC yuanlong$ ./loanCalc Enter amount of loan: $ 500 Enter Interest rate per year: % 7.5 Enter number of payments: 5 Monthly payment should be 101.88 AMORTIZATION SCHEDULE # Payment Principal Interest Balance 1 $101.88 $ 98.76 $ 3.12 $401.24 2 $101.88 $ 99.38 $ 2.51 $301.87 3 $101.88 $ 100.00 $ 1.89 $201.87 4 $101.88 $ 100.62 $ 1.26 $101.25 5 $101.88 $ 101.25 $ 0.63 $0.00Explanation / Answer
#include<stdio.h>
#include<math.h>
int main()
{
float r,l,intrest,mp,c,balance,principle;
int n,i;
//taking user input...
printf("Enter loan amount:");
scanf("%f",&l);
printf("Enter interest rate per year:");
scanf("%f",&r);
printf("Number of payments:");
scanf("%d",&n);
c=r/(100*12);
mp=l*c*(pow(1+c,n))/(pow(1+c,n)-1);
printf("monthly amount hould be %f ",mp);
printf("# Paymen Principle intrest Balance ");
intrest=r*balance/1200;
balance=l+intrest;
for(i=1;i<=n;i++)//printing output
{
intrest=r*balance/1200;
principle=mp-intrest;
balance =balance-mp;//total amount
if(balance<0)
balance=0;
printf("%d %f% %f %f %f ",i,mp,principle,intrest,balance);
}
return 0;
}
Output:
Enter loan amount:500
Enter interest rate per year:7.5
Number of payments:5
monthly amount hould be 101.882408
# Paymen Principle intrest Balance
1 101.882408 98.757408 3.125000 398.117584
2 101.882408 99.394173 2.488235 296.235168
3 101.882408 100.030937 1.851470 194.352753
4 101.882408 100.667702 1.214705 92.470345
5 101.882408 101.304466 0.577940 0.000000
Process exited normally.
Press any key to continue . . .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.