Originally Posted by
IntheRearWithTheGear
Below is the sort of function im working to get the true number - can anybody see issue ? note the recursion.
static public double CalcInterest(double InterestRate, int Months, double LoanAmount)
{
double TotalInterest = 0;
for (int i = 1; i < Months + 1; i++)
{
double PmtValue = Financial.Pmt(InterestRate / 12, Months, -LoanAmount);
double IPmtValue = Financial.IPmt(InterestRate / 12, i, Months, -LoanAmount);
double PPmtValue = Financial.PPmt(InterestRate / 12, i, Months, -LoanAmount);
TotalInterest += IPmtValue - ( (IPmtValue * 0.175) + (IPmtValue * 0.15) );
if(PPmtValue + IPmtValue > 0.01)
{
TotalInterest = TotalInterest + CalcInterest(InterestRate, Months - i, IPmtValue + PPmtValue);
}
//Console.WriteLine("{0},{1},{2},{3}", i, PmtValue, PPmtValue, IPmtValue);
}
return TotalInterest;
}