等额本金,等额本息,随借随还,利随本清,按月付息到期还本,5种还款方式java计算方法
等额本金,等额本息,随借随还,利随本清,按月付息到期还本,5种还款方式java计算方法
等额本息定义:本金逐月递增,利息逐月递减,月还款数不变。
等额本金定义:本金保持相同,利息逐月递减,月还款数递减。
随借随还定义:客户在获得授信额度后可以随时来支取,借出后就开始算利息;借出后可以随时还。还了之后在期限内又可以取。
利随本清(一次性还本付息)定义:借款人在贷款期内不是按月偿还本息,而是贷款到期后一次性归还本金和利息。
按月付息到期还本定义:借款人每月只交付利息,在贷款到期日时一次性归还贷款本金
//等额本息
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;/*** 等额本息还款,也称定期付息,即借款人每月按相等的金额偿还贷款本息,其中每月贷款利息按月初剩余贷款本金计算并逐月结清。把按揭贷款的本金总额与利息总额相加,* 然后平均分摊到还款期限的每个月中。作为还款人,每个月还给银行固定金额,但每月还款额中的本金比重逐月递增、利息比重逐月递减。*/public class AverageCapitalPlusInterestUtils {/*** 等额本息计算获取还款方式为等额本息的每月偿还本金和利息* * 公式:每月偿还本息=〔贷款本金×月利率×(1+月利率)^还款月数〕÷〔(1+月利率)^还款月数-1〕* * @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalmonth* 还款总月数* @return 每月偿还本金和利息,不四舍五入,直接截取小数点最后两位*/public static double getPerMonthPrincipalInterest(double invest, double yearRate, int totalmonth) {double monthRate = yearRate / 12;BigDecimal monthIncome = new BigDecimal(invest).multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth))).divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_DOWN);return monthIncome.doubleValue();}/*** 等额本息计算获取还款方式为等额本息的每月偿还利息* * 公式:每月偿还利息=贷款本金×月利率×〔(1+月利率)^还款月数-(1+月利率)^(还款月序号-1)〕÷〔(1+月利率)^还款月数-1〕* @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalmonth* 还款总月数* @return 每月偿还利息*/public static Map<Integer, BigDecimal> getPerMonthInterest(double invest, double yearRate, int totalmonth) {Map<Integer, BigDecimal> map = new HashMap<Integer, BigDecimal>();double monthRate = yearRate/12;BigDecimal monthInterest;for (int i = 1; i < totalmonth + 1; i++) {BigDecimal multiply = new BigDecimal(invest).multiply(new BigDecimal(monthRate));BigDecimal sub = new BigDecimal(Math.pow(1 + monthRate, totalmonth)).subtract(new BigDecimal(Math.pow(1 + monthRate, i-1)));monthInterest = multiply.multiply(sub).divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 6, BigDecimal.ROUND_DOWN);monthInterest = monthInterest.setScale(2, BigDecimal.ROUND_DOWN);map.put(i, monthInterest);}return map;}/*** 等额本息计算获取还款方式为等额本息的每月偿还本金* * @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalmonth* 还款总月数* @return 每月偿还本金*/public static Map<Integer, BigDecimal> getPerMonthPrincipal(double invest, double yearRate, int totalmonth) {double monthRate = yearRate / 12;BigDecimal monthIncome = new BigDecimal(invest).multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth))).divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_DOWN);Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, totalmonth);Map<Integer, BigDecimal> mapPrincipal = new HashMap<Integer, BigDecimal>();for (Map.Entry<Integer, BigDecimal> entry : mapInterest.entrySet()) {mapPrincipal.put(entry.getKey(), monthIncome.subtract(entry.getValue()));}return mapPrincipal;}/*** 等额本息计算获取还款方式为等额本息的总利息* * @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalmonth* 还款总月数* @return 总利息*/public static double getInterestCount(double invest, double yearRate, int totalmonth) {BigDecimal count = new BigDecimal(0);Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, totalmonth);for (Map.Entry<Integer, BigDecimal> entry : mapInterest.entrySet()) {count = count.add(entry.getValue());}return count.doubleValue();}/*** 应还本金总和* @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalmonth* 还款总月数* @return 应还本金总和*/public static double getPrincipalInterestCount(double invest, double yearRate, int totalmonth) {double monthRate = yearRate / 12;BigDecimal perMonthInterest = new BigDecimal(invest).multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth))).divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_DOWN);BigDecimal count = perMonthInterest.multiply(new BigDecimal(totalmonth));count = count.setScale(2, BigDecimal.ROUND_DOWN);return count.doubleValue();}
//等额本金
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;/*** 等额本金是指一种贷款的还款方式,是在还款期内把贷款数总额等分,每月偿还同等数额的本金和剩余贷款在该月所产生的利息,这样由于每月的还款本金额固定,* 而利息越来越少,借款人起初还款压力较大,但是随时间的推移每月还款数也越来越少。*/
public class AverageCapitalUtils {/*** 等额本金计算获取还款方式为等额本金的每月偿还本金和利息* * 公式:每月偿还本金=(贷款本金÷还款月数)+(贷款本金-已归还本金累计额)×月利率* * @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalMonth* 还款总月数* @return 每月偿还本金和利息,不四舍五入,直接截取小数点最后两位*/public static Map<Integer, Double> getPerMonthPrincipalInterest(double invest, double yearRate, int totalMonth) {Map<Integer, Double> map = new HashMap<Integer, Double>();// 每月本金double monthPri = getPerMonthPrincipal(invest, totalMonth);// 获取月利率double monthRate = yearRate / 12;monthRate = new BigDecimal(monthRate).setScale(6, BigDecimal.ROUND_DOWN).doubleValue();for (int i = 1; i <= totalMonth; i++) {double monthRes = monthPri + (invest - monthPri * (i - 1)) * monthRate;monthRes = new BigDecimal(monthRes).setScale(2, BigDecimal.ROUND_DOWN).doubleValue();map.put(i, monthRes);}return map;}/*** 等额本金计算获取还款方式为等额本金的每月偿还利息* * 公式:每月应还利息=剩余本金×月利率=(贷款本金-已归还本金累计额)×月利率* * @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalMonth* 还款总月数* @return 每月偿还利息*/public static Map<Integer, Double> getPerMonthInterest(double invest, double yearRate, int totalMonth) {Map<Integer, Double> inMap = new HashMap<Integer, Double>();double principal = getPerMonthPrincipal(invest, totalMonth);Map<Integer, Double> map = getPerMonthPrincipalInterest(invest, yearRate, totalMonth);for (Map.Entry<Integer, Double> entry : map.entrySet()) {BigDecimal principalBigDecimal = new BigDecimal(principal);BigDecimal principalInterestBigDecimal = new BigDecimal(entry.getValue());BigDecimal interestBigDecimal = principalInterestBigDecimal.subtract(principalBigDecimal);interestBigDecimal = interestBigDecimal.setScale(2, BigDecimal.ROUND_DOWN);inMap.put(entry.getKey(), interestBigDecimal.doubleValue());}return inMap;}/*** 等额本金计算获取还款方式为等额本金的每月偿还本金* * 公式:每月应还本金=贷款本金÷还款月数* * @param invest* 总借款额(贷款本金)* @param totalMonth* 还款总月数* @return 每月偿还本金*/public static double getPerMonthPrincipal(double invest, int totalMonth) {BigDecimal monthIncome = new BigDecimal(invest).divide(new BigDecimal(totalMonth), 2, BigDecimal.ROUND_DOWN);return monthIncome.doubleValue();}/*** 等额本金计算获取还款方式为等额本金的总利息* * @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalMonth* 还款总月数* @return 总利息*/public static double getInterestCount(double invest, double yearRate, int totalMonth) {BigDecimal count = new BigDecimal(0);Map<Integer, Double> mapInterest = getPerMonthInterest(invest, yearRate, totalMonth);for (Map.Entry<Integer, Double> entry : mapInterest.entrySet()) {count = count.add(new BigDecimal(entry.getValue()));}return count.doubleValue();}
//随借随还/** 随借随还* @param amount 本金* @param annualInterestRate 年利率* @param termCount 还款期限(天数)* @return 还款金额 = 本金 + 本金*日利率*天数* @throws Exception*/public static BigDecimal payOff(BigDecimal amount, BigDecimal annualInterestRate, int termCount) throws Exception {annualInterestRate = annualInterestRate.multiply(new BigDecimal(100));BigDecimal dailyInterest = LoanUtil.getDayInterestByYear(annualInterestRate);BigDecimal multiply = amount.multiply(dailyInterest).multiply(new BigDecimal(termCount));return multiply.add(amount).setScale(2, BigDecimal.ROUND_HALF_EVEN);}
//利随本清/*** @Title: calculateInterest 利息总计 = 本金*利率*数* @Description: TODO(利随本清利息计算)* @param @param amount 本金* @param @param annualInterestRate 年利率* @param @param termUnit 1为日利率 3为月利率* @param @param termCount 日数,月数* @param @return 利随本清方式利息总计* @param @throws Exception参数 * @return BigDecimal 返回类型* @throws**/public static BigDecimal calculateInterest(BigDecimal amount,BigDecimal annualInterestRate, int termUnit, int termCount) throws Exception{annualInterestRate = annualInterestRate.multiply(new BigDecimal(100));if (termUnit == 1) {BigDecimal dailyInterest = LoanUtil.getDayInterestByYear(annualInterestRate);return amount.multiply(dailyInterest).multiply(new BigDecimal(termCount)).setScale(2,BigDecimal.ROUND_HALF_EVEN);} else if (termUnit == 3) {BigDecimal monthlyInterest = LoanUtil.getMonthInterestByYear(annualInterestRate);return amount.multiply(monthlyInterest).multiply(new BigDecimal(termCount)).setScale(2, BigDecimal.ROUND_HALF_EVEN);} else {throw new Exception("不支持的时间单位: " + termUnit);}}
//按月付息到期还本/*** 按月付息,到期还本-计算获取还款方式为按月付息,到期还本的每月偿还利息* * 公式:每月应还利息=总借款额*年利率÷还款月数** * @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalMonth* 还款总月数* @return 每月偿还利息*/public static double getPerMonthInterests(double invest,double yearRate, int totalMonth) {BigDecimal monthIncome = new BigDecimal(invest).multiply(new BigDecimal(yearRate)).divide(new BigDecimal(totalMonth), 2, BigDecimal.ROUND_DOWN);return monthIncome.doubleValue();}/*** 按月付息,到期还本计算获取还款方式为按月付息,到期还本的每月偿还利息,最后一个月归还利息+本金* * 公式:每月偿还利息=(总借款额*年利率÷还款月数)* * @param invest* 总借款额(贷款本金)* @param yearRate* 年利率* @param totalMonth* 还款总月数* @return 每月偿还利息,不四舍五入,直接截取小数点最后两位*/public static Map<Integer, Double> getPerMonthPrincipalInterests(double invest, double yearRate, int totalMonth) {Map<Integer, Double> map = new HashMap<Integer, Double>();// 每月利息double monthPri = getPerMonthInterests(invest,yearRate, totalMonth);for (int i = 1; i <= totalMonth; i++) {if(i == totalMonth){//最后一期 利息+ 本金monthPri = monthPri + invest ;}map.put(i, monthPri);}return map;}
等额本金,等额本息,随借随还,利随本清,按月付息到期还本,5种还款方式java计算方法相关推荐
- C#实现的等额本息法、按月付息到期还本法、一次性还本付息法
你若懂行,那便有用,如下: void Main() { var x = DengEBenXi.Compute(11111, 12, 3); x.Dump(); var y = ...
- 等额本金等额本息工具类2023
等额本金&等额本息工具类2023 等额本金 等额本金 问题反馈 等额本金 import java.math.BigDecimal; import java.math.RoundingMode; ...
- 等额本金,等额本息,分期付息到期还本,到期还本还息计算实现
闲来无事,将之前的一些工具类实现整理出来,以相互借鉴,共同探讨学习. 如果有发现什么不明白或者bug欢迎留言. package com.hansy.p2p.tool;import java.math. ...
- java 等额本金等额本息工具类
2019独角兽企业重金招聘Python工程师标准>>> 等额本息: /*** Description:等额本息工具类* Copyright: Copyright (corporati ...
- 银行业务中贷款算法等额本金等额本息算法程序
写一个贷款计算器,从网上找了一个算法,自己改了改可以用了,不错,分享给大家 import java.text.DecimalFormat; public class jshk { public sta ...
- 如何使用python进行等额本金-等额本息贷款计算
#贷款额为a,月利率为i,年利率为I,还款月数为n a = 500000.00 I = 0.11495 i = I/12 n = 60 print("-----等额本息计算,以5个月为例-- ...
- 等额本金.等额本息.房贷计算
<?phpfunction debx(){$dkm = 12; //贷款月数,20年就是240个月$dkTotal = 2000; //贷款总额$dknl = 0.049; //贷款年利率$em ...
- 贷款还款方式(等额本金,等额本息,等本等息,先息后本)
等额本金 月还款总额逐月降低 月还款本金固定,为贷款总金额÷期数 月还款利息逐渐降低,为每月剩余贷款余额×单期利息 图例: 本金10000 月息1% 贷款12期 月还款本金=10000÷12=833. ...
- Java计算等额本金和等额本息
Java计算等额本金和等额本息 等额本金 等额本息 等额本金 /*** 等额本金是指一种贷款的还款方式,是在还款期内把贷款数总额等分,每月偿还同等数额的本金和剩余贷款在该月所产生的利息,这样由于每月的 ...
最新文章
- 大数据-07-Spark之流数据
- node2vec python_node2vec应用记录
- 脑电分析系列[MNE-Python-9]| 参考电极应用
- 【Pygame小游戏】这款经典的炸弹人超能游戏上线,你爱了嘛?(附源码)
- 笔记-信息系统开发基础-uml-uml类图关系
- java 监控usb端口插拔_如何监控某种类型的USB设备的插拔?
- linux伙伴系统接口,Linux伙伴系统(一)--伙伴系统的概述
- 清华博士庞天宇90页的PPT分享,如何让AI模型更皮实,更稳定?(精彩直播回放)...
- 概率图模型的d-separation概念
- 手游的巨头时代,中小厂商该何去何从?
- Vultr VPS修改root密码的方法
- 如何在vm虚拟机里面安装win10操作系统
- 人工智能与复杂网络_为什么我与智能手机的关系变得复杂
- 用机器学习颠覆环法自行车赛传统体验 岱凯野心可不只有这一点!
- 如何靠区块链赚钱?区块链到底是不是骗局?
- Studio 3T 的Query Builder使用
- ip2region 使用总结
- 【MEMS】【1】微机电系统与比例尺度定律(尺寸效应)
- Android学习记录——8.多媒体
- 菜鸟零基础建站入门指引(仅供参考)
热门文章
- 微信小程序商城开发,可以用个人银行卡收款吗?
- 面向 Java 人员的 Python
- 使用FFMpeg将MP4转为m3u8
- ejs渲染html无效,express设置ejs渲染.html文件
- 生鲜价目表制作 水果价目表 蔬菜价目表
- ssh用于验证,https://github.com/?需要,https://www.cloudcontrol.com/onboarding/ssh也需要。...
- 什么是“老三论”、“新三论”
- 华测RTK X10的使用和数据的导出
- 批量抓取title keywords descrip【seo工具】
- 《炬丰科技-半导体工艺》介电蚀刻工艺中等离子体的蚀刻处理