java 等额本息计算方式

本文详细介绍了投资理财中等额本息计算的方式,包括本金、年利率、期限的计算,以及每月本息金额、本金、利息的计算过程。通过实例计算,展示了等额本息还款的实际应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

投资理财,等额本息计算方式

以下按照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%

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值