135k views
0 votes
Implement this C program by defining a structure for each payment. The structure should have at least three members for the interest, principle and balance separately. And store all the payments in a structure array (the max size of which could be 100). Name this C program as loanCalcStruct.c. Note: . In your answer sheet, for each C program above please attach a screenshot of the output when amount of loan is $2000, interest rate per year is %7.5 and number of payment is 6. . Put the source code of each C program above into your answer sheet Upload the c file of each Cprogram above into the submission folder of iCollege.

User Gullbyrd
by
4.0k points

1 Answer

2 votes

Answer:

#include<stdio.h>

#include<math.h>

void output_amortized(float loan_amount,float intrest_rate,int term_years)

{

int i,j; //Month

int payments; //Number of payments

float loanAmount; //Loan amount

float anIntRate; //Yealy interest Rate

float monIntRate; //Monthly interest rate

float monthPayment; //Monthly payment

float balance; //Balance due

float monthPrinciple; //Monthly principle paid

float monthPaidInt; //Month interest paid

balance=loan_amount;

//Calculations

//Monthly interest rate

monIntRate = ((intrest_rate/(100*12)));

//Monthly payment

payments=term_years;

monthPayment = (loan_amount * monIntRate * (pow(1+monIntRate, payments)/(pow (1+monIntRate, payments)-1)));

monthPaidInt = balance * monIntRate;

//Amount paid to principle

monthPrinciple = monthPayment-monthPaidInt;

//New balance due

balance = balance - monthPrinciple;

printf("\\\\Monthly payment should be :%.2f\\\\",monthPayment);

printf("============================AMORTIZATION SCHEDUAL==========================\\");

printf("#\tPayment\t\tIntrest\t\tPrinciple\t\tBalance\\");

for(i=0;i<payments;i++)

{

printf("%d%9c%.2f%9c%.2f%16c%.2f%14c%.2f\\",(i+1),'$',monthPayment,'$',monthPaidInt,'$',monthPrinciple,'$',balance);

monthPaidInt = balance * monIntRate;

//Amount paid to principle

monthPrinciple = monthPayment-monthPaidInt;

//New balance due

balance = balance - monthPrinciple;

}

}

int main()

{

float principle,rate;

int termYear;

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

scanf("%f",&principle);

printf("Enter the intrest rate :%");

scanf("%f",&rate);

printf("Enter the loan duration in years: ");

scanf("%d",&termYear);

output_amortized(principle,rate,termYear);

}

Step-by-step explanation:

see output

Implement this C program by defining a structure for each payment. The structure should-example-1
User Brian Slesinsky
by
4.0k points