1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
int main ()
{
float total;
int Month = 1;
float PR;
float IY;
int NY;
int NM;
float IM;
float P;
float Q;
float MP;
float Interest;
float balance;
printf("Amount of the loan (principal)?");
scanf("%d", &PR);
printf("Intrest rate per year (percent)");
scanf("%d", &IY);
printf("Number of years?");
scanf("%d", NY);
NM = NY * 12;
IM = (IY / 12) / 100;
P = (1 + IM) ^ NM;
Q = (P/ (P - 1));
MP = (PR * IM * Q);
Interest = PR * IM;
printf("The amount of the loan (principal): %d", PR);
printf("Intrest rate/year (percent): %d", IY);
printf("Intrest rate/month (decimal): %d", IM);
printf("Number of years: %d", NY);
printf("number of months: %d", NM);
printf("Monthly payment: %F", MP);
printf("\n");
printf("Month\t Old Balance\t Monthly Payment\t Interest Paid\n Principal Paid\t New Balance");
while (Month <= NM)
{
printf("%d\t %f\t %F\t %f\t %f\t %f", Month++, PR - (MP - Interest), MP, Interest, MP - Interest, PR - (MP - Interest));
total += MP + Interest;
}
printf("%f", total);
return 0;
}
|