[up]

Math


Well, the obligatory factorial example:

    100 factorial


An interest rate calculator:

    |initialAmount sep|

    initialAmount := 100 asFixedPoint:2.
    sep := '+---+'.
    1 to:20 do:[:years | sep := sep , '-------+'].
    Transcript showCR:sep.

    #(0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.20) do:[:percentF |
	|percent|
	percent := percentF asFixedPoint:2.
	Transcript show: '|'.
	Transcript show: ((percent * 100) asInteger printStringLeftPaddedTo:2); show: '%'.
	Transcript show: '|'.
	1 to:20 do:[:years |
	    |amount|
	    amount := initialAmount * ((1 + percent) raisedTo:years).
	    Transcript show: (amount printStringLeftPaddedTo:7).
	    Transcript show: '|'.
	].
	Transcript cr.
	Transcript showCR:sep.
    ].
BTW, this should tell you, why you should never lend money for more than a (say) 7% interest rate, and that CEOs primising a continued return on capital of 20% over many years are criminal liars ;-)


... I will add some of my secrets here soon ...


Back to "Using Workspaces".

[stx-logo]
Copyright © Claus Gittinger Development & Consulting
Copyright © eXept Software AG

<cg@exept.de>

Doc $Revision: 1.1 $ $Date: 2006/10/13 12:06:07 $