我写了一个小的 jQuery 兴趣计算器。
- 它正在计算每月还款的信用额度
问题是我的利息计算逻辑完全是错误的。
看一看:
//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>');
}
}
}
你们中有人在做类似的事情吗?如何计算具有以下信息的利息:
- 月数/年数 (
i = months
) - 月供金额 (
$('form input[name="val1"]').val();
) - 存款金额 (
j = deposit
) - 利率 (
g = interest rate
)
正如你所看到的,循环是针对月/存款/利息的。只需要一些帮助登录计算循环中的兴趣。