I wrote small jQuery interest calulcator.
The problem is that my interest calculation logic is just purely wrong.
Have a look:
//Get the value - monhtly repayment
var InputedValue = $('form input[name="val1"]').val();
// 12 ,18, 24, 30, 36 - NumberOfMonths
for (var i = 12; i <= 36; i += 12) {
// j = 20 - Deposit in %
for (var j = 10; j <= 10; j += 10) {
// g = 20, 30 - InterestPerYear in %
for (var g = 10; g <= 10; g += 10) {
var InScaleOfYear = i / 12;
// Amount of payment excluding deposit
var AmountOfPayments = (InputedValue * (i - 1)); // rat bedzie o jedna mniej niz ilosc miesiecy, bo wplata poczatkowa
// Amount of payment including deposit
var AmountInTotal = (AmountOfPayments * 100) / (100 - j);
// Deposit
var Deposit = AmountInTotal - AmountOfPayments;
// Amount of payment in one year
var AmountOfPaymentInOneYear = (AmountOfPayments / InScaleOfYear);
var InterestPerYear = ((AmountOfPaymentInOneYear * g) / 100);
// Interest in total
var InterestInTotal = InterestPerYear * InScaleOfYear;
// Amount of credit
var AmountOfCredit = (AmountOfPayments + Deposit) - InterestInTotal;
$('table tbody').append('<tr><td>'
+ i + '</td><td>'
+ "at " + j + "% = " + Deposit.toFixed(2) + '</td><td>'
+ "at " + g + "% = " + InterestPerYear.toFixed(2) + '</td><td>'
+ "at " + g + "% = " + InterestInTotal.toFixed(2) + '</td><td>'
+ AmountOfPayments.toFixed(2) + '</td><td>'
+ AmountInTotal.toFixed(2) + '</td><td>'
+ AmountOfCredit.toFixed(2) + '</td></tr>');
}
}
}
Any of you working on something similar? How can I calculate interest having following information:
i = months
)$('form input[name="val1"]').val();
)j = deposit
)g = interest rate
)As you can see, the loop is in place for months/deposit/interest. Just need some help with the login of calculating interest in the loop.
The main issue is that you're trying to solve a calculus problem by using non-calculus methods. Calculus, if you aren't aware, is a branch of mathematics for essentially trying to solve for X/0 problems. In the case of compound interest, it's a case of greedy banks trying to squeeze as much money as possible from the interest.
This started out as monthly interest, but they realized that if they charged per day, they could get more. It's the same interest of say, 10% per month, divided into days as 1/3% per day. That's because the interest from the previous day is part of the calculation (or compounded) for next interest cycle. They could get more if they divided per hour, per minute, per second, until it became basically "instant interest". Thus, compound interest is born.
(Because of the popularity and confusion, the govt mandated the use of the APR term to translate the compound interest percentage into an "Annual Percentage Rate" that us normal people can relate to. So, if it says APR, and most do, it's compound interest.)
Compound interest is a X/0 problem, because you trying to get instant interest. Wikipedia's article on compound interest should provide some useful formulas for calculating compound interest. However, one important thing to remember when using formulas like these is that you can't just take something like APR and divide by 12 to get a MPR figure. Otherwise, it wouldn't be compound interest, and it's not that simple.