ANNUITY Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
ANNUITY Function
The ANNUITY function (annuity immediate) returns a numeric value that is
the ratio of an annuity paid at the end of each period for the number of
periods specified by parameter-2 to an initial investment of one.
Interest is earned at the rate specified by parameter-1 and is applied at
the end of the period before the payment. The function type is numeric.
Syntax
FUNCTION ANNUITY (parameter-1 parameter-2)
Parameters
parameter-1 Must be class numeric and must be greater than or
equal to zero.
parameter-2 Must be a positive integer.
Return Value
When the value of parameter-1 is zero, the value of the function is
1
parameter-2
When the value of parameter-1 is not zero, the value of the function is
parameter-1
(1 - (1 + parameter-1) ** (- parameter-2))
Example
WORKING-STORAGE SECTION.
77 NUM-RATE PIC S9V9999 VALUE 0.08.
77 MONTHLY-RATE PIC S9V9999 VALUE ZERO.
77 NUM-PERIODS PIC 99 VALUE 36.
77 NUM-ANNUITY PIC S9V9999 VALUE ZERO.
PROCEDURE DIVISION.
010-PARA.
COMPUTE MONTHLY-RATE ROUNDED = NUM-RATE / 12
COMPUTE NUM-ANNUITY ROUNDED =
FUNCTION ANNUITY (MONTHLY-RATE NUM-PERIODS)
DISPLAY MONTHLY-RATE
DISPLAY NUM-PERIODS
DISPLAY NUM-ANNUITY.
The above example displays the following:
+0.0067
36
+0.0314
MPE/iX 5.0 Documentation