(Comparing loans with various interest rates) Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each annual interest rate starting from 5% to 8%, with an increment of 1/8. Suppose you enter the loan amount 10,000 for five years;

a) Display a table as follows:

Loan Amount: 10000

Number of Years: 5

Interest Rate Monthly Payment Total Payment

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

5% 188.71 11322.74

5.125% 189.28 11357.13

5.25% 189.85 11391.59

...

7.85% 202.16 12129.97

8.0% 202.76 12165.83

The formula to compute the monthly payment is as follows:

http://www14.0zz0.com/2010/02/26/13/516993313.png
You don't have to know how this formula is derived. Nonetheless, given the monthly interest rate, number of years, and loan amount, you can use it to compute the monthly payment.

Compute the total payment, which is the monthly payment multiplied by 12 and multiplied by the number of years.

I wrote program for first question , can anybody help me with writing program for Q.2? .

b) If a person can pay monthly around a given amount (for example 200±5), and he wants to take a given loan (for example 10000).

Let the program find how many years needed (between 5 and 15) and what the value of the annualInterstRate (between 5% and 8% with an increment of 1/8.) supposed to be, to pay the taken loan.

(Find all the possibilities in which the person can pay).
Code:

#include <stdio.h>
#include <stdlib.h>
int main()
{
float m,t;
float p,w,y,r;
printf("Enter loan amount :-\n");scanf("%f",&p);
printf("Enter loan period , with years :-\n");scanf("%f",&y);
printf("Intrest rate Monthly payment Total payment\n");
printf("--------------------------------------------\n");
for(r=5;r<=8;r=r+0.125){
w=pow((1+(r/(12*100))),(12*y));
m=((r/(12*100))*p*w)/(w - 1);
t=m*12*y;
printf("%.3f\t\t%.2f\t\t%.2f",r,m,t);
printf("\n");
}
return 0;
}