1. ok i got the pow formula to work. KNow my issues is with my AmountIntrest .
Code:
`AmountInterest = a  * (1 + i/12);`
Here you are applying a years worth of interest each month. You read in an annual interest rate. As was done in the formula I provided, you have to adjust that for just one month.
so would that mean ti would have to write it as
Code:
` AmountInterest = ( pow(1 + i / 12,  n)*a;`
This way it si deviding the months by the interest the * by the currentanount ler me knwo if you want to see the rest of the program.

2. Originally Posted by redmondtab
ok i got the pow formula to work. KNow my issues is with my AmountIntrest .
Code:
`AmountInterest = a  * (1 + i/12);`
Here you are applying a years worth of interest each month. You read in an annual interest rate. As was done in the formula I provided, you have to adjust that for just one month.
so would that mean ti would have to write it as
Code:
` AmountInterest = ( pow(1 + i / 12,  n)*a;`
This way it si deviding the months by the interest the * by the currentanount ler me knwo if you want to see the rest of the program.
.
I don't think you need to be using the pow function at all for this bit. The monthly interest would be the amount outstanding times the interest rate divided by 12.

So that seems to be simply:- a*i/12. (a =ammount outstanding)
(Of course I am assuming that the interest rate is defined as "the interest rate which can be applied monthly to pay off the loan ).

3. yeah i finally under stand that know. I was trying to take it from a % to a demical. Which i did not need to do. Go figure. THanks for the help on this one

4. I think your logic in simplifing the formula is flawed, but I can't prove it.
Code:
`( pow(1 + i / 12,  n) * (i / 12 * a) ) /  (pow(1 + i / 12,  n) – 1 )`
(because for example 5*5*5*5/5*5*5 = 5)
No it doesn't, unless you meant (5*5*5*5)/(5*5*5) = 5.

5. Originally Posted by dwks
I think your logic in simplifing the formula is flawed, but I can't prove it.
Code:
`( pow(1 + i / 12,  n) * (i / 12 * a) ) /  (pow(1 + i / 12,  n) – 1 )`

No it doesn't, unless you meant (5*5*5*5)/(5*5*5) = 5.
Yes that is what I mean't maybe I should have put:-

5*5*5*5
-----------
5*5*5

Which was what I was thinking.

6. Maybe . . . but I don't think your local compiler will like so many minuses in a row. I know what you mean.

7. Originally Posted by dwks
I think your logic in simplifing the formula is flawed, but I can't prove it.
Code:
`( pow(1 + i / 12,  n) * (i / 12 * a) ) /  (pow(1 + i / 12,  n) – 1 )`
Refering to that bit, the quoted formula above is not the formula I simplified, I simplified
the formula he mistakenly originally used. :-
( pow(1 + i / 12, n) * (i / 12 * a) ) / (pow(1 + i / 12, n – 1 ))

The formula you quoted cannot be simplified, or at least no one has managed it yet
(and I am sure many eminent mathemeticains have tried!!)

8. Originally Posted by esbo
Refering to that bit, the quoted formula above is not the formula I simplified, I simplified
the formula he mistakenly originally used. :-
( pow(1 + i / 12, n) * (i / 12 * a) ) / (pow(1 + i / 12, n – 1 ))

The formula you quoted cannot be simplified, or at least no one has managed it yet
(and I am sure many eminent mathemeticains have tried!!)
That's what I was trying to point out.

9. ok i need my teach is dead set that is is correct. Can some one pleae run this and tell me if the get teh correct answers

Code:
```/*************************************************************
File Name:     Tmitchellwk1
Description:   Display Loan Amortization Schedule
Date:          August 28th, 2006
Designer;      Tabatha Mitchell
Assignment:    week1
Functions:      None
**************************************************************/
#include <stdio.h>
#include <math.h>

/*Program to compute Amortization Schedule*/

main  ()
{

int   TermLoan,  // length of the loan
Numberofmonths, //Number of months in the loan
count,
n,c; //Letters used for the calculations
double   AmountPrinciple, //Amount paid on principle
AmountInterest,  //amount paid to interest
LoanBlance, //amount owed on loan\ count,
CurrentBlance,
LoanAmount, //amount of the loan
InterestRate, //interest rate on loan
a,i,
NewBlance, //amount of new amount owed
PaymentAmount;  //amount paid to loan

//start of main program
printf ("Please enter in loan amount, Term of Loan in months and Interest Rate.\n");

while (scanf("%lf%d%lf", &LoanAmount, &TermLoan, &InterestRate) != 3
|| (LoanAmount < 0 || TermLoan < 0 || InterestRate < 0 ))
{
while ((c = getchar()) != '\n' && c != EOF);
printf ("Please re-enter in loan amount, Term of Loan in months and Interest Rate.\n");
}
CurrentBlance = LoanAmount;
Numberofmonths = TermLoan;
i = InterestRate;
n = Numberofmonths;
a = CurrentBlance;
PaymentNumber = 0;
count = 0;

printf ("\amortization Schedule\n");
printf ("_____________________\n");

PaymentAmount = pow((1+i/12),n)*(i/12*a)/pow((1+i/12),n)-1;

while(PaymentNumber < Numberofmonths)
{
//[ (1 + i / 12) ** n * (i / 12 * a) ] / [ (1 + i / 12) ** n – 1 ]

PaymentNumber++; //Start number of months for amortization schedule
count++;
AmountInterest = a  * (i/12);
AmountPrinciple = PaymentAmount - AmountInterest;
LoanBlance = a -AmountPrinciple;
printf ("CurrentBlance %.2f\n", a);
printf ("InterestRate %.2f\n", i);
printf ("PaymentNumber %d\n",  PaymentNumber);
printf ("LoanBlance  %.2f\n", LoanBlance);
printf ("PaymentAmount %.2f\n", PaymentAmount);
printf ("AmountPrinciple %.2f\n", AmountPrinciple);
printf  ("AmountInterest %.2f\n", AmountInterest);
printf ("_______________________\n\n");
a = LoanBlance;
}//end of while loop

getchar ();
getchar ();
printf ("hit enter to end");
return 0;
}```

10. Code:
```getchar ();
getchar ();
printf ("hit enter to end");```
The user will never see that printf(); put it before the getchar()s. And in case there's more than just a newline sitting in the input buffer you might want to do this instead:
Code:
```int c;
while((c = getchar()) != '\n' && c != EOF);```
http://faq.cprogramming.com/cgi-bin/...&id=1043284392

11. Dose the math work for you. I'm getting wrong number but was told that this is how the calcualtions should be?

12. Start with a really simple test, something which is paid off in say 3 months, so you don't get vast amounts of output to deal with.

Do you have a specimen output to compare against?

Have you done the calculations by hand?

Have you tried to use the debugger - a marvellous program which allows you to step through your code one line at a time, and examine all the variables as you're going along. Most good compilers come with some sort of a debugger.

13. Code:
`>        PaymentAmount = pow((1+i/12),n)*(i/12*a)/pow((1+i/12),n)-1;`
I think you're missing some parentheses. I think it should be:
Code:
`        PaymentAmount = ( pow((1+i/12),n)*(i/12*a) ) / ( pow((1+i/12),n)-1 );`

14. Ive tried that and it is not giving me the right payment amount.

i did something simple and this is what i came up with
Please enter in loan amount, Term of Loan in months and Interest Rate.

1000.00 12 12

Amortization Schedule

_____________________

CurrentBlance 1000.00

InterestRate 12.00

PaymentNumber 1

LoanBlance 1001.00

PaymentAmount 999.00

AmountPrinciple -1.00

AmountInterest 1000.00

_______________________

CurrentBlance 1001.00

InterestRate 12.00

PaymentNumber 2

LoanBlance 1003.00

PaymentAmount 999.00

AmountPrinciple -2.00

AmountInterest 1001.00

_______________________

CurrentBlance 1003.00

InterestRate 12.00

PaymentNumber 3

LoanBlance 1007.00

PaymentAmount 999.00

AmountPrinciple -4.00

AmountInterest 1003.00

_______________________

15. I suggest that if you're doing a complicated calculations, why not take it one at a time, rather than making a single line of code full blast.

After doing the correct formula, then shrink it to single line.