等额本息还款,也称定期付息,即借款人每月按相等的金额偿还贷款本息,其中每月贷款利息按月初剩余贷款本金计算并逐月结清。把按揭贷款的本金总额与利息总额相加,然后平均分摊到还款期限的每个月中。作为还款人,每个月还给银行固定金额,但每月还款额中的本金比重逐月递增、利息比重逐月递减。
每月还款额计算公式如下:
每月还款额=[贷款本金×月利率×(1+月利率)^还款月数]÷[(1+月利率)^还款月数-1]
java代码如下:
import java.math.BigDecimal;
/**
* 等额本息还款算法
* Created by FuYung on 2015/8/3.
*/
public class PrincipalAndInterestEquals {
/**
* @param args
*/
public static void main(String[] args) {
BigDecimal invest = new BigDecimal(139000); // 本金
double yearRate = 0.059; // 年利率
int year = 15;//期限
double monthRate = yearRate / 12;
int month = year * 12;
// 每月本息金额 = (本金×月利率×(1+月利率)^还款月数)÷ ((1+月利率)^还款月数-1)
BigDecimal monthIncome = invest.multiply(new BigDecimal(monthRate * Math.pow(1 +
monthRate, month))).divide(new BigDecimal(Math.pow(1 + monthRate, month) - 1), 2,
BigDecimal.ROUND_HALF_UP);
System.out.println("每月本息金额 : " + monthIncome);
System.out.println("---------------------------------------------------");
// 每月本金 = 本金×月利率×(1+月利率)^(还款月序号-1)÷((1+月利率)^还款月数-1)
BigDecimal monthCapital;
BigDecimal sumCapital = BigDecimal.ZERO;
for (int i = 1; i < month + 1; i++) {
monthCapital = invest.multiply(new BigDecimal(monthRate * (Math.pow((1 + monthRate),
i - 1)))).divide(new BigDecimal(Math.pow(1 + monthRate, month) - 1), 2,
BigDecimal.ROUND_HALF_UP);
System.out.println("第" + i + "月本金: " + monthCapital);
sumCapital = sumCapital.add(monthCapital);
}
System.out.println("---------------------------------------------------");
// 每月利息 = 剩余本金 x 贷款月利率
BigDecimal monthInterest;
BigDecimal capital = invest;
BigDecimal tmpCapital = BigDecimal.ZERO;
BigDecimal sumInterest = BigDecimal.ZERO;
for (int i = 1; i < month + 1; i++) {
capital = capital.subtract(tmpCapital);
monthInterest = capital.multiply(new BigDecimal(monthRate)).setScale(2, BigDecimal
.ROUND_HALF_UP);
tmpCapital = invest.multiply(new BigDecimal(monthRate * (Math.pow((1 + monthRate), i
- 1)))).divide(new BigDecimal(Math.pow(1 + monthRate, month) - 1), 2,
BigDecimal.ROUND_HALF_UP);
System.out.println("第" + i + "月利息: " + monthInterest);
sumInterest = sumInterest.add(monthInterest);
}
System.out.println("本金总和:" + sumCapital + " 利息总和:" + sumInterest);
}
}