`
raymond.chen
  • 浏览: 1418000 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

等额本金还款

 
阅读更多

等额本金:每月的还款额不同,呈现逐月递减的状态;它是将贷款本金按还款的总月数均分,再加上上期剩余本金的利息,这样就形成月还款额,所以等额本金法第一个月的还款额最多,然后逐月减少,越还越少。

 

/**
	 * 等额本金还款法
	 * @param _loanAmount 贷款金额(元)
	 * @param _loanYears 贷款年数
	 * @param _annualInterestRate 贷款年利率(%)
	 */
	private static void averageCapital(double _loanAmount, int _loanYears, double _annualInterestRate){
		BigDecimal digit_0 = new BigDecimal(0); //数字0
		BigDecimal digit_100 = new BigDecimal(100); //数字100
		BigDecimal monthsOfYear = new BigDecimal(12); //一年的月数
		int scale = 10; //精度
		
		BigDecimal loanTotal = new BigDecimal(_loanAmount);	//贷款总额,元为单位
		BigDecimal loanYears = new BigDecimal(_loanYears); //贷款年数
		BigDecimal annualInterestRate = new BigDecimal(_annualInterestRate).divide(digit_100); //年利率
		
		//还款月数
		int loanMonths = loanYears.multiply(monthsOfYear).intValue();
		System.out.println("还款月数:" + loanMonths);
		
		//月利率 = 年利率 /12。一般以千分之表示
		BigDecimal monthlyInterestRate = annualInterestRate.divide(monthsOfYear, scale, BigDecimal.ROUND_HALF_UP);
		System.out.println("月利率:" + toFixed(monthlyInterestRate.multiply(new BigDecimal(1000)), 3));
		
		//每月本金=总本金/还款月数
		BigDecimal monthlyPrincipal = loanTotal.divide(new BigDecimal(loanMonths), scale, BigDecimal.ROUND_HALF_UP);
		
		BigDecimal accruedPrincipal = digit_0; //累计本金
		BigDecimal totalInterest = digit_0; //累计利息

		System.out.println("\n期数,还款本息(元),还款利息(元),还款本金(元),剩余本金(元)");
		for(int n=1; n<=loanMonths; n++){
			//每月还款本息 =(本金/还款月数)+(本金-累计已还本金)×月利率
			BigDecimal bx1 = loanTotal.divide(new BigDecimal(loanMonths), scale, BigDecimal.ROUND_HALF_UP);
			BigDecimal bx2 = loanTotal.subtract(accruedPrincipal).multiply(monthlyInterestRate);
			BigDecimal monthlyRepaymentAmount = bx1.add(bx2);
			
			//每月利息 = (本金-累计已还本金)×月利率
			BigDecimal lx = loanTotal.subtract(accruedPrincipal).multiply(monthlyInterestRate);
			
			//总利息
			totalInterest = totalInterest.add(lx);
				
			//累计已还本金
			accruedPrincipal = accruedPrincipal.add(monthlyPrincipal);
			
			//剩余本金 = 本金-累计已还本金
			BigDecimal remainingPrincipal = loanTotal.subtract(accruedPrincipal);
				
			System.out.println(n + "," + toFixed(monthlyRepaymentAmount, 2) + "," + toFixed(lx, 2) + "," + toFixed(monthlyPrincipal, 2) + "," + toFixed(remainingPrincipal, 2));
		}
		
		System.out.println("总利息:" + toFixed(totalInterest, 2));
		System.out.println("还款总金额:" + toFixed(loanTotal.add(totalInterest), 2));
	}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics