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

C Programming.Use Code: :Blocks to write a program to solve this problem. Loan p

ID: 3674703 • Letter: C

Question

C Programming.Use Code: :Blocks to write a program to solve this problem.

Loan payments.

Compute a table that shows a monthly payback schedule for a loan. The principle amount of the loan, the annual interest rate, and the monthly payment amount are to be read as inputs. Calculate the monthly interest rate as 1/12 of the annual rate. Each month, rst calculate the current interest = the monthly rate * the loan balance. Then add the interest amount to the balance, subtract the payment, and print this new balance. Continue printing lines for each month until the normal payment would exceed the loan balance. On that month, the payment amount should be the remaining balance and the new balance becomes 0. Print a neat loan repayment table following this format:

Payment schedule for $1000 loan at 0.125 annual interest rate and monthly payment of $100.00

Month       Interest      Payment      Balance

--------------------------------------------------------

1            10.42          100.00         910.42

2               9.48         100.00         819.90

...               ...                ...                  ...

10             1.66          100.00         60.99

11             0.64           61.63           0.00

--------------------------------------------------------

Notes: Be careful of your pennies and rounding. Add up your result and make sure it is correct, as if you do NOT do anything special for the rounding issue, your result will be incorrect. The incorrect lines are NOT shown in the Book/PDFs.

SAMPLE INPUT:
1000
.125
100

SAMPLE OUTPUT:

Spring 2016 Problem#4 CSCI1110

----PARTIAL SAMPLE OUTPUT:
8           3.68        100      256.66

Explanation / Answer

#include <stdio.h>

int main (void)

{

/*declaring variables for printing table*/

    float prin_amount, interest_rate, monthly_payment, monthly_amount,m_ins,current_ins;

    int m;     

/*reading principle amount of the loan, the annual interest rate, and the monthly payment amount*/

printf("Enter priniciple amount ");

   scanf("%f", & prin­_amount);

    printf("Enter Interest rate:");

    scanf("%f", &interest_rate);

    printf("Enter Monthly Payment:");

    scanf("%f", &monthly_payment);

//calculating monthly interest

m_ins= interest_rate/12;

//calculating loan balance i.e balance amount

loan_balance= (prin_amount + (prin_amount*m_ins))- monthly_payment;

//initialize month=1       

m=1;

printf("---------------------------------------------------------");

printf("Month       Interest      Payment      Balance");

//for month1

Printf("%d                   %.2f                  %2f                      %2f   ",m, m_ins, monthly_payment, loan_balance);

//executes until monthly payment is grater than loan balance

while(monthly_payment>loan_balance)

{

m++;

current_ins= m_ins* loan_balance;

loan_balance= (loan_balance+ (loan_balance* current_ins)) – (monthly_payment);

//calculates monthly payment

if(loan_balance <monthly_payment)

monthly_payment =

(monthly_payment – (monthly_payment- loan_balance))+( loan_balance* current_ins);

   Printf("%d                   %.2f                  %2f                      %2f   ",m, current_ins, monthly_payment, loan_balance);

}//while

printf("---------------------------------------------------------");

return 0;

}//main