home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP21.EXE / CHP2107.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  1.0 KB  |  45 lines

  1. /*
  2.    Listing 21.7  Interest functions
  3.    Author: Joe Booth
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11.  
  12. function simple(nPrin,nRate,nPeriods)
  13. return nPrin * (nRate*nPeriods)
  14.  
  15.  
  16. function compound(nPrin,nRate,nPeriods,cFreq)
  17. LOCAL jj,arr_:={},multiplier:=1
  18. cFreq:=if(cFreq=NIL,"Q",cFreq)
  19. if cFreq = "C"
  20.    multiplier := Exp(nRate)
  21. elseif cFreq = "A"
  22.    multiplier := (1+nRate)
  23. elseif cFreq = "Q"
  24.    multiplier := (1+nRate/4)**4
  25. elseif cFreq = "M"
  26.    multiplier := (1+nRate/12)**12
  27. endif
  28. Aadd(arr_,nPrin*multiplier)
  29. for jj=2 to nPeriods
  30.    Aadd(arr_,arr_[jj-1]*multiplier)
  31. next
  32. return arr_
  33.  
  34.  
  35. function pv(payment,rate,periods)
  36. LOCAL multi:= (1-((1+Rate)**(-1*periods))) / rate
  37. return multi * payment
  38.  
  39.  
  40. function fv(payment,rate,periods)
  41. LOCAL multi:= (((1+Rate)**periods)-1) / rate
  42. return multi * payment
  43.  
  44. // end of file CHP2107.PRG
  45.