I can't get my formula to work

I'm having trouble getting the following to work

#include<iostream.h>
#include<math.h>
#include<iomanip.h>
main ()
{
int PaymentNum=1;
float MonthlyPymt=165.25;
float InterestRte=(9.00/12.00);
float Balance=MonthlyPymt*(1-(pow((1+InterestRte),(PaymentNum-36)))/InterestRte);
do
{
cout.setf (ios::floatfield, ios::showpoint);
cout.setf (ios::fixed);
cout<<"\nMonthly Payment: $"<< setprecision(2)<< MonthlyPymt;
cout<<"\nMonthly Interest Rate: "<< setprecision(2)<< InterestRte;
cout<<"\nTotal Payments: "<< setprecision(0)<< PaymentNum;
cout<<"\nBalance: $"<< setprecision(2)<< Balance;
cout<<"\n";
PaymentNum +=1;
}
while (PaymentNum !=4);
system ("pause");
return 0;
}



My teacher told me the Balance formula has to be in the LOOP function, but it still doesn't work. I always get the same number over and over. The program has to determine a Balance, then it should decrease as the number of payments increases. The formula the teacher provided for the balance is Monthly Payment[1-(1+Interest rate per month)^Payment Number-Total Number of Payments (its 36) / Interest Rate
This doesn't really help you with your immediate problem, but you might want to take a look at some functional languages, later on. Particularly Haskell. I think you'd get along with them.
Topic archived. No new replies allowed.