Kbase P90451: How to raise a number to a power using 4GL?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/26/2004 |
|
Status: Unverified
GOAL:
How to raise a number to a power using 4GL?
FIX:
Use the Progress 4GL EXP function which returns the result of raising a number to a power. The following sample procedure uses the EXP function to calculate the future value of an principal amount invested at a given compounded annual interest rate over a specified number of years:
DEFINE VARIABLE principal AS DECIMAL FORMAT "->>>,>>9.99" LABEL "Principal".
DEFINE VARIABLE rate AS INTEGER FORMAT "->9" LABEL "Interest %".
DEFINE VARIABLE num-yrs AS INTEGER FORMAT ">>9" LABEL "Years".
DEFINE VARIABLE final-amt AS DECIMAL FORMAT "->>>,>>>,>>>,>>>,>>>,>>9.99" LABEL "Final Amount".
REPEAT:
UPDATE principal rate num-yrs.
final-amt = principal * EXP(1 + rate / 100,num-yrs).
DISPLAY final-amt.
END.