Mircrosoft Excel PPMT function in Java

Basic Description

The Excel PPMT function calculates the payment on the principal, during a specific period of a loan or investment that is paid in constant periodic payments, with a constant interest rate.

The syntax of the function is:
PPMT( rate, per, nper, pv, [fv], [type] )
Where the arguments are as follows:

rate - The interest rate, per period.
per - The period for which the payment on the principal is to be calculated (must be an integer between 1 and nper).
nper - The number of periods over which the loan or investment is to be paid.
pv - The present value of the loan / investment.
[fv] - An optional argument that specifies the future value of the loan / investment, at the end of nper payments. If omitted, [fv] takes on the default value of 0.
[type] - An optional argument that specifies whether the payment is made at the start or the end of the period.
             The [type] argument can have the value 0 or 1, meaning:
                   0   -   The payment is made at the end of the period;
                   1   -   The payment is made at the start of the period.
             If the [type] argument is omitted, it takes on the default value of 0 (denoting payments made at the end of the period).

The function can be represented in Java as:


static public double ppmt(double r, int per, int nper, double pv, double fv, int type) {        return pmt(r, nper, pv, fv, type) - ipmt(r, per, nper, pv, fv, type);    }

Full source code can be found at: ExcelFunctions.java

0 comments:

Post a Comment