投资理财,等额本息计算方式
以下按照10000元,以年利率15.5%,投资期限为6个月,以等额本息方式偿还来计算
/**
* 等额本息计算
*/
public class PrincipalAndInterestEquals {
public static void main(String[] args) {
double invest = 10000; //贷款本金
double yearRate = 0.155; //年利率
double monthRate = yearRate/12; //月利率
// int year = 15; //还款年数
int month = 6; //还款月数
System.out.println("本金-->"+invest+" 年利率--->"+yearRate*100+"%"+" 期限--->"+month+"个月");
System.out.println("--------------------------------------------");
// 每月本息金额 = (本金×月利率×(1+月利率)^还款月数)÷ ((1+月利率)^还款月数-1))
double monthIncome = (invest* monthRate * Math.pow(1+monthRate,month))/(Math.pow(1+monthRate,month)-1);
System.out.println("每月本息金额 : " + monthIncome);
System.out.println("---------------------------------------------------");
// 每月本金 = 本金×月利率×(1+月利率)^(还款月序号-1)÷((1+月利率)^还款月数-1))
double monthCapital = 0;
for(int i=1;i<month+1;i++){
monthCapital = (invest* monthRate * (Math.pow((1+monthRate),i-1)))/(Math.pow(1+monthRate,month)-1);
System.out.println("第" + i + "月本金: " + monthCapital);
}
System.out.println("---------------------------------------------------");
// 每月利息 = 剩余本金 x 贷款月利率
double monthInterest = 0;
double capital = invest;
double tmpCapital = 0;
double totalInterest = 0;
for(int i=1;i<month+1;i++){
capital = capital - tmpCapital;
monthInterest = capital * monthRate;
tmpCapital = (invest* monthRate * (Math.pow((1+monthRate),i-1)))/(Math.pow(1+monthRate,month)-1);
System.out.println("第" + i + "月利息: " + monthInterest);
totalInterest = totalInterest + monthInterest;
}
System.out.println("-------------------------------------------------");
System.out.println("利息:--->"+totalInterest);
System.out.println("-------------------------------------------------");
System.out.println("年利率:--->"+totalInterest/month*12/invest*100+"%");
}
/**
* 获取每月本息金额
* 计算方式
* 每月本息金额 = (本金×月利率×(1+月利率)^还款月数)÷ ((1+月利率)^还款月数-1))
* @param invest 本金
* @param yearRate 年利率
* @param month 还款月
* @return 每月本息金额
*/
public double getMonthIncome(double invest, double yearRate,int month){
double monthRate = yearRate/12; //月利率
double monthIncome = (invest* monthRate * Math.pow(1+monthRate,month))/(Math.pow(1+monthRate,month)-1);
return monthIncome;
}
}
本金-->10000.0 年利率--->15.5% 期限--->6个月
--------------------------------------------
每月本息金额 : 1742.8196429537836
---------------------------------------------------
第1月本金: 1613.6529762871169
第2月本金: 1634.495993897492
第3月本金: 1655.6082338186682
第4月本金: 1676.9931735054925
第5月本金: 1698.6543353299387
第6月本金: 1720.5952871612835
---------------------------------------------------
第1月利息: 129.16666666666666
第2月利息: 108.3236490562914
第3月利息: 87.21140913511546
第4月利息: 65.82646944829101
第5月利息: 44.16530762384506
第6月利息: 22.224355792500013
-------------------------------------------------
利息:--->456.91785772270964
-------------------------------------------------
年利率:--->9.138357154454193%
所以当我们以15.5%的年利来进行等额本息理财的时候,其实换算之后,年利率只相当于百分之9%