The amortized schedule shows the amounts that go towards interest and principal
ID: 3918467 • Letter: T
Question
The amortized schedule shows the amounts that go towards interest and principal for each month. Write a function that takes the loan terms as parameters and prints the amortized schedule. The function header and a sample output are shown below. The rightmost two columns (INTEREST, PRINCIPAL) are cumulative figures and show the total interest and principal paid to date. Like the sample below, print the year number only for the first month of the year and print the header again for each year void output_amortized (double loan_amount, double interest_rate, double term_years): Year Month Interest Principal Balance INTEREST PRINCIPAL 500 498 496 494 492 490 488 486 484 481 479 610 149390 I 612 148779 614 148165 616 147550 I 618 146932 I 620 146312 I 622 145690 624 145066 I 626 144440 I 628 143812 I 630 143182 I 632 142550 I 500 998 1494 1988 2480 2969 3457 3943 4426 4908 5387 5864 610 1221 1835 2450 3068 3688 4310 4934 5560 6188 6818 7450 10 12 Year Month Interest Principal Balance INTEREST PRINCIPAL 13 14 15 475 473 471 634 141916 I 636 141279 639 140641 6340 6813 7284 8084 8721 9359Explanation / Answer
here is your program : ------------->>>>>>>>>>
#include<stdio.h>
#include<math.h>
void output_amortized(double loan_amount,double interest_rate,double trems_year){
double totTerm = trems_year * 12;
double r = interest_rate / 12;
r = r/100;
double pAmount = loan_amount * ((r*(pow((1+r),totTerm)))/(pow(1+r,totTerm) - 1));
r = r*100;
double int_am = 0.0;
double totPAm = 0;
double totInt = 0;
int i,j;
for(i = 1;i <= (int)trems_year;i++){
printf(" --------------------------------------------------------------------");
printf(" %4s%7s%10s%11s%9s%3s%10s%11s","Year","Month","Interest","Principal","Balance","|","INTEREST","PRINCIPAL");
printf(" --------------------------------------------------------------------");
for(j = 1;j<13;j++){
int_am = loan_amount*r/100;
totInt += int_am;
totPAm += (pAmount - int_am);
loan_amount -= (pAmount - int_am);
if(j == 1){
printf(" %4d%7d%10d%11d%9d%3s%10d%11d",i,j,(int)int_am,(int)(pAmount - int_am),(int)loan_amount,"|",(int)totInt,(int)totPAm);
}else{
printf(" %11d%10d%11d%9d%3s%10d%11d",j,(int)int_am,(int)(pAmount - int_am),(int)loan_amount,"|",(int)totInt,(int)totPAm);
}
}
}
}
int main(){
output_amortized(100000,6,6);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.