Equal interest repayment, also known as regular interest payments, that is, the borrower monthly repayment of the loan principal and interest of equal amount, of which the monthly loan interests of the loan at the beginning of the month and month to settle. The total principal amount of the mortgage loan is added to the total amount of interest and then evenly distributed to each month of the repayment period. As the repayment of the person, each month to the bank fixed amount, but the monthly repayment amount of the principal proportion of month-on-month increase, interest ratio monthly decline.
The monthly repayment amount is calculated as follows:
Monthly repayment Amount =[loan Principal x monthly interest rate X (1+ month interest rate) ^ Payment month]÷[(1+ month rate) ^ Repayment month-1]
The Java code is as follows:
import java.math.bigdecimal;/** * matching principal and interest repayment algorithm * created by fuyung on 2015/8/3. */public class principalandinterestequals { /** * @param args */ Public static void main (String[] args) { bigdecimal invest = new bigdecimal (139000); // principal double yearRate = 0.059; // Annual interest Rate int year = 15;//term double monthRate = yearRate / 12; int month = year * 12; // monthly principal and interest amount = (Principal x monthly interest rate X (1+ monthly rate) ^ repayment months)÷ ((1+ monthly rate) ^ Repayment month-1) bigdecimal monthincome = invest.multiply (New bigdecimal (Monthrate * math.pow (1 + monthrate, month)). Divide (new) bigdecimal (Math.pow (1 + monthrate, month) - 1), 2, &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;BIGDECIMAL.ROUND_HALF_UP); system.out.println ("monthly principal and interest amount : " + monthincome); system.out.println ("------------------------------------------------ ---"); // monthly principal = Principal x monthly interest rate X (1+ monthly interest rate) ^ (Repayment month number-1) ÷ ((1 + Monthly rate) ^ Repayment month-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 + "monthly Principal" + monthcapital); &nbSp;sumcapital = sumcapital.add (monthcapital); } system.out.println ("------------------------------------------------ ---"); // monthly interest = remaining principal x loan monthly interest rate 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); &nbSp; 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, &NBSP;&NBSP;&NBSP;BIGDECIMAL.ROUND_HALF_UP); system.out.println (" + i + Monthly interest: " + monthinterest); suminterest = Suminterest.add (monthinterest); } system.out.println ("Sum of Principal:" + sumCapital + " interest sum:" + suminterest); }}
The algorithm of bank matching and principal repayment