Well, I overlooked the code and I believe you are close. You just need to study functions and return values some more. You have a habit of using return 0; when, say, returning the variable the user just entered would have been more helpful. You will also need to assign these return values to variables in main in order to use them across multiple functions. Importantly, count_d() and count_e().
As for the math I think I can help you there. The formula I think you are trying to use, and that you should be using anyway, is the calculation for a monthly payment: c = Pr / (1 - (1 / (1 + r)n)). As for the interest, you just multiply c*r. It's important to remember that the rate is monthly interest, so in effect, divide the annual rate by 12 first.
Then using the formulas to make the table might look like this, as a small example:
Code:
void plan (float bal, int yrTerm, float yrRate)
{
int month = 0, months = yrTerm * 12;
float payment = 0;
float interest = 0;
printf("Month, Old Balance, Payment, Interest, New Balance\n");
printf("---------------------------------------------------\n");
for ( ; month < months; month++)
{
payment = MonthlyPayment(bal, yrRate / 12.0f, months - month);
interest = yrRate / 12.0f * payment;
printf("%d\t%.02f\t%.02f\t%.02f\t%.02f\n", month + 1, bal, payment, interest, bal + interest - payment);
bal += interest;
bal -= payment;
}
}
Month, Old Balance, Payment, Interest, New Balance
---------------------------------------------------
1 500.00 45.03 0.55 455.51
2 455.51 44.49 0.54 411.56
3 411.56 43.96 0.53 368.13
4 368.13 43.43 0.53 325.23
5 325.23 42.91 0.52 282.84
6 282.84 42.40 0.52 240.96
7 240.96 41.89 0.51 199.58
8 199.58 41.39 0.50 158.70
9 158.70 40.89 0.50 118.31
10 118.31 40.40 0.49 78.40
11 78.40 39.92 0.49 38.97
12 38.97 39.44 0.48 0.01
Beware of tiny accounting errors.