这里我有一个计算季度复利经常性存款的公式:
<script type="text/javascript">
function Function() {
amount = 1000;
months = 18;
intrest = 12;
quaters = Math.floor(months / 3);
monthpayment = parseInt(amount) * ((Math.pow(intrest / 400 + 1, quaters) - 1) / (1-(Math.pow(intrest / 400 + 1,(-1/3)))));
newpayment = monthpayment - amount * months;
document.getElementById("MaturityAmt").value = monthpayment.toFixed(2);
document.getElementById("IntrestAmt").value = newpayment.toFixed(2);
document.getElementById("Deposit").value=(monthpayment.toFixed(2)-newpayment.toFixed(2))
}
此处需要更改哪些内容才能获得按年复利的经常性存款:例如: 本金 1000 分 18 个月分期付款,每年复利 12%。
总投资:18000 到期值(value):19713.24,赚取利息:1713.24
最佳答案
演示片段
rd();
$("input").on('keyup', function(){
rd();
});
function rd(){
var p = $("#installment").val(),
i = $("#interest").val(),
n = $("#month").val(),
e = Math.pow((1+i/400), n/3),
d = Math.pow((1 + i/400),(-1/3)),
m = (p*(e - 1))/(1 - d);
$(".m").text("Maturity amount = " + m.toFixed(2));
$(".n").text("Instalment amount = " + p*n);
$(".o").text("Interest amount = " + (m - p*n).toFixed(2));
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
<label>Monthly instalment</label>
<input type="number" id="installment" placeholder="Monthly instalment" value="1000">
</div>
<div>
<label>Rate of interest</label>
<input type="number" id="interest" placeholder="6.40" value="6.40">
</div>
<div>
<label>No of months</label>
<input type="number" id="month" placeholder="12" value="12">
</div>
<h3 class="m"></h3>
<h3 class="n"></h3>
<h3 class="o"></h3>
您还可以查看codepen demo
关于javascript - 需要一个公式来计算年复利经常性存款,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37039071/