一,等额本息工具类
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(

最低0.47元/天 解锁文章
1405

被折叠的 条评论
为什么被折叠?



