Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Setup Anim
detecting hard disk
E-mailExec 2.01
Media Development
Set PlayBackMode of a Flash Sprite
zLaunch
Valentina Spider 1.0
DMFade
Sound on/off - MCI
SID6581
 

 

 

Behavior Compound Interest

Added on 5/27/2001

 

Compatibilities:
behavior D6_5 D7 D8 D8_5 Mac PC Shockwave

Rating:

Author: KurtKoenig (website)

This behavior calculates the interest on your savings over a number of years,and shows the amount after each year...

Download PC Source    Download Mac Source
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--   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

Send e-mail