Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C program named loanCalc.c that calculates monthly payment and print a t

ID: 3813513 • 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 http://www.bankrate.Com/calculators/mortgages/loan-calculator.aspx In this C program, the input and output are defined as following: Input: amount of loan, interest rate per year and number of payments 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: yuan long $ ./loanCalc Enter amount of loan: $500 Enter Interest rate per year: %7.5 Enter number of payments: 5 Montly payment should be 101.88

Explanation / Answer

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main ()

{

double loanAmount;

double interestRate;

double interstPerMonth;

double numerator;

double denominator;

double interest;

double emi;

int numberOfPayments;

int i=0;

  

printf ("Enter amount of loan : $");

scanf("%lf",&loanAmount);

  

printf ("Enter Interest rate per year : %%");

scanf("%lf",&interestRate);

  

printf ("Enter number of payments : ");

scanf("%d",&numberOfPayments);

  

interstPerMonth = (interestRate/1200);

  

numerator = pow(1+interstPerMonth,numberOfPayments);

denominator = numerator -1;

  

emi = loanAmount*interstPerMonth*numerator/denominator;

  

printf(" Monthly payment should be %.2lf", emi);

  

printf(" ==============================AMORTIZATION SCHEDULE============================");

printf(" # Payment Principle Interest Balance");

for(i=1; i <= numberOfPayments; i++) {

interest = loanAmount*interstPerMonth;

loanAmount = loanAmount - (emi - interest);

printf(" %-3d $%-8.2lf $%-8.2lf $%-8.2lf $%-8.2lf ", i, emi, emi-interest, interest, loanAmount );

}

  

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote