我寫了一個小型jQuery興趣卡爾魯克。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
)
正如你所看到的,這個循環已經存在幾個月/存款/利息。只需要一些在循環中計算興趣的登錄幫助。
我不確定你的問題是否與編程有關。你正在尋找一個函數來計算基於某些變量的興趣,對吧? - 會幫助你嗎? http://math.about.com/od/businessmath/ss/Interest.htm – polarblau
@polarblau - 以及如何使用JavaScript做到這一點? – Iladarsda
瞭解如何在沒有Javascript的情況下做到這一點。鏈接(以及許多其他在線資源)將幫助您。然後將該函數翻譯成Javascript。 – polarblau