100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > js月份的计算公式_JS实现招财宝约定年化收益率6.30%(按月等额本金还款)计算公式...

js月份的计算公式_JS实现招财宝约定年化收益率6.30%(按月等额本金还款)计算公式...

时间:2023-09-17 13:30:40

相关推荐

js月份的计算公式_JS实现招财宝约定年化收益率6.30%(按月等额本金还款)计算公式...

自己写了个程序,算了下招财宝的约定年化收益率6.30%(按月等额本金还款),发现相当于到期一次性还本付息的年化收益率3.4128%,感觉自己被坑了。。。

以下为JS代码,以本金10000元,期限1年为例:

document.writeln("

document.writeln("

");

document.writeln("

月份");

document.writeln("

剩余本金");

document.writeln("

已归还本金");

document.writeln("

已归还收益");

document.writeln("

累计已归还本金");

document.writeln("

累计已归还收益");

document.writeln("

");

varx=10000,y=12,z=(x/y).toFixed(2);//本金,时长(月),每月返还本金数

varp=0.063;//约定年化收益率

vars1=0,s2=0;//累计已归还本金,累计已归还收益

varm=x,n;//剩余本金,已归还收益

document.writeln("

");

document.writeln("

0");

document.writeln("

"+x+"");

document.writeln("

0");

document.writeln("

0");

document.writeln("

0");

document.writeln("

0");

document.writeln("

");

for(vari=1;i<=y;i++){

document.writeln("

");

document.writeln("

"+i+"");//月份

n=(x*p/12).toFixed(2);//已归还收益

x=(x-z).toFixed(2);//剩余本金

document.writeln("

"+x+"");//剩余本金

document.writeln("

"+z+"");//已归还本金

document.writeln("

"+n+"");//已归还收益

s1=(Number(s1)+Number(z)).toFixed(2);//累计已归还本金

document.writeln("

"+s1+"");//累计已归还本金

s2=(Number(s2)+Number(n)).toFixed(2);//累计已归还收益

document.writeln("

"+s2+"");//累计已归还收益

document.writeln("

");

}

document.writeln("

");

说明:以上代码并没有什么卵用,仅供娱乐和学习参考。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。