 Sulphy - 3 years ago 362
C# Question

# Amortization schedule calculation with differing results

I'm attempting to build a small program to generate a string output which will tell me the total repayable amount for a loan (compound interest on a monthly basis). I'm using two online calculators to validate my workings, however both differ to one another.

• Loan amount: 1000

• Rate: 7%

• Duration:36 months

• Monthly repayable: 30.78

• Total repayable: £1108.04 (this is close to the result I'm
expecting)

The above is validated via the following online calculator: https://www.moneysupermarket.com/loans/calculator/

However, on pretty much every other online calculator I get:

• Monthly repayable: 30.88

• Total repayable: £1,111.53

Examples:

https://en-gb.calculatestuff.com/financial/loan-amortization-calculator

http://www.calculator.net/amortization-calculator.html?cloanamount=1000&cloanterm=3&cinterestrate=7&printit=0&x=69&y=15

Furthermore in my own code I get 1,111.53. So I'm a bit confused as to which end value is correct. I'd like to get closer to the first amount of 1,108.04 as thats the value I've been asked to find, but not sure what I'm missing here.

`````` public void CompoundCalculator(double lenderRate, double loanPeriodInMonths, double desiredLoanAmount){
var repaymentAmount = PMT(7, 36, 1000);
var balance = desiredLoanAmount;
var totalInterest = 0.00;

for (var i = 0; i < loanPeriodInMonths;i++)

{
var monthlyInterest = Math.Round(balance * ( (lenderRate / 1200) ),2);

balance -= Math.Round(repaymentAmount - monthlyInterest,2) ;
totalInterest += monthlyInterest;

}
//do something here later with totalInterest variable

}

public static double PMT(double yearlyInterestRate, int totalNumberOfMonths, double loanAmount)
{
var rate = (double)yearlyInterestRate / 100 / 12;
var denominator = Math.Pow((1 + rate), totalNumberOfMonths) - 1;
return (rate + (rate / denominator)) * loanAmount;
}
`````` WNG
``````Math.Pow(1+(yearlyInterestRate / 100),1.0/12)-1