---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
-- Compound Interest
--
-- This behavior calculates the interest on your savings over a number of years,
-- and displays the amount after each year...
--
-- Kurt * Belgium 2001
--
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
-- variables are: A = Nr of years, B = Startamount,
-- I = Interest rate, E = Final amount after Nr of years
global A, B, I, E
-- First the mousedown handler to clear
-- the previous contents of the output field on mousedown
-- (so it becomes more visible that the field is cleared each time,
-- if you use (member "Output").text = "" in a moviescripts
-- on startmovie handler, the field will be empty each time
-- the movie starts...
on mousedown
(member "Output").text = ""
end mousedown
-- On mouseup, the new calculation is made
-- In Belgium the used formula for compound
-- Interest = E = (B * (1 + float(I)/ 100)),
-- the same formula is used in other country's to(I think...)
-- to show the result for the last year only
-- you have to use: power (E = (B * (1 + float(I)/ 100)), A)
-- (might be a small diversion in syntax, I didn't try this...)
on mouseup
(member "Output").text = ""
the floatprecision = 2
B = (member "C.I") . text
A = (member "Years") . text
I = (member "InterestRate") . text.float
repeat with Ix = 1 to A
E = (B * (1 + float(I)/ 100))
B = E
put E&&"after"&&Ix&&"years." into (member "Output").line[Ix]
end repeat
clearglobals
end mouseup
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA