Java Monthly interest rate calculation (equal and principal loan)

Source: Internet
Author: User
Tags pow

Monthly repayment calculation formula of equal and principal interest:

Monthly principal and interest amount = (Principal x monthly rate X (1+ month rate) ^ repayment month) ÷ ((1+ monthly rate) ^ Repayment month-1))

Reverse Seeking Moon interest rate

The monthly rate is not calculated if it is reversed according to the above formula.

Here is a calculation of the specific test, starting from 1 to reduce the 0.1, reduced to 0.1 after each reduction, 0.01

/*** Project name:cfss_asws1 * File Name:NiTui.java * Package Name:test * date:2018 year August 16 afternoon 5:40:07 * Copyright (c) 2018 * Company: Shenzhen Ping An comprehensive financial Services Co., Ltd. All rights Reserved. *  */ PackageORG.AGONCAL.SAMPLE.JMH;/*** Classname:nitui <br/> * Function:todo add Function. <br/> * Reason:todo add Reason. <br/> * Dat E: August 16, 2018 PM 5:40:07 <br/> * *@authorZHANGZHEN626 *@version * @sinceJDK 1.6 *@see */ Public classNitui {/*** Rate: (here is a word describing the effect of this method). <br/> * TODO (described here to apply the condition – optional) .<br/> * TODO (here describes the execution process of this method – optional) .<br/> * TODO (this describes how this method is used – optional) .<br/> * TODO (this method is described here for considerations – optional) .<br/> * *@authorZHANGZHEN626 *@parama loan amount *@paramb Monthly Payment (monthly repayment amount) *@paramC Period of repayment *@paramCNT iterative test times *@paramINA is accurate to several decimal places. * @return     * @sinceJDK 1.6*/     Public Static DoubleRateDoubleADoubleBDoubleCintCntintINA) {        DoubleRate = 1, x, JD = 0.1, side = 0.1, I = 1;  Do{x= A/b-(Math.pow (1 + rate, c)-1)/(Math.pow (rate + 1, c) *Rate ); if(x * side > 0) {side= -side; JD*= 10; } Rate+ = Side/JD; }  while(i++ < CNT && Math.Abs (x) >= 1/math.pow (10, Ina));//if (i > CNT)//return Double.NaN;        returnRate ; }     Public Static voidMain (String agrs[]) {{//Double Present value = 7944760.00d; //Double annuity = 186627.21d; //Double number of periods = 48d; //calculated 200 times, less accurate than EXCEL20, error accurate to 10 digits after decimal pointSYSTEM.OUT.PRINTLN (Rate (150000, 6000, 36, 2111, 10)); }    }}

Java Monthly interest rate calculation (equal and principal loan)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.