Java之~ 等额本息,等额本金,组合贷

一,等额本息工具类

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

/**
 * 等额本息还款,也称定期付息,即借款人每月按相等的金额偿还贷款本息,其中每月贷款利息按月初剩余贷款本金计算并逐月结清。把按揭贷款的本金总额与利息总额相加,
 * 然后平均分摊到还款期限的每个月中。作为还款人,每个月还给银行固定金额,但每月还款额中的本金比重逐月递增、利息比重逐月递减。
 */

public class AverageCapitalPlusInterestUtils {

      public static final int MO =12;    
//    public static void main(String[] args) {
//        double invest = 1000000; // 本金
//        int totalMonth = 10;
//        double yearRate = 0.049; // 年利率
//        
////        Map<String ,Object> result = getAverageCapitalPlusInterest(invest, yearRate, totalMonth);
//        System.out.println(getAverageCapitalPlusInterestAll(500000, 0.0325, 500000, 0.049, 10));
//    }
    
    /**
     * 等额本息
     * @param invest  总金额
     * @param yearRate  年利率
     * @param totalMonth  贷款年限
     * @return
     */
    public static Map<String ,Object> getAverageCapitalPlusInterest(double invest, double yearRate, int totalMonth) {
        int month = totalMonth*MO;
        
        Map<String ,Object> result = new HashMap<String ,Object>();
        
        BigDecimal benxi = getPerMonthPrincipalInterest(invest, yearRate, month);
        Map<Integer, BigDecimal> mapPrincipal = getPerMonthPrincipal(invest, yearRate, month);
        Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, month);
        BigDecimal lixicount = getInterestCount(invest, yearRate, month);
        BigDecimal allcount = getPrincipalInterestCount(invest, yearRate, month);
        
        
        result.put("allMonth", month);//总月数
        result.put("benxi", benxi);//成本+利息
//        result.put("benjin", mapPrincipal.get(1));//首月本金
//        result.put("firstMapInterest", mapInterest.get(1));//首月利息
        result.put("lixicount", lixicount);//总利息
        result.put("allcount", allcount);//本息合计
        
        System.out.println("等额本息---每月本息:" + benxi);
        System.out.println("等额本金---首月本金:" + mapPrincipal.get(1));
        System.out.println("等额本息---每月本金:" + mapPrincipal);
        System.out.println("等额本息---每月利息:" + mapInterest);
        System.out.println("等额本息---首月利息:" + mapInterest.get(1));
        System.out.println("等额本息---总利息:" + lixicount);
        System.out.println("等额本息---本息合计:" + allcount);
        return result;
    }
    
    /**
     * 等额本息组合贷
     * @param invest1 公基金
     * @param yearRate1 公积金年利率
     * @param invest2 商贷金额
     * @param yearRate2 商贷年利率
     * @param totalMonth 贷款年限
     * @return
     */
    public static Map<String ,Object> getAverageCapitalPlusInterestAll(double invest1, double yearRate1, double invest2, double yearRate2,int totalMonth) {
        int month = totalMonth*MO;
        
        Map<String, Object> map = new HashMap<String, Object>();
        
        //成本+利息
        BigDecimal benxi1 = getPerMonthPrincipalInterest(invest1, yearRate1, month);
        //总利息
        BigDecimal lixicount1 = getInterestCount(invest1, yearRate1, month);
        //合计
        BigDecimal allcount1 = getPrincipalInterestCount(invest1, yearRate1, month);
        
        //成本+利息
        BigDecimal benxi2 = getPerMonthPrincipalInterest(

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值