CAPDM Tutorial Applets

Present Value

Functionality:

This applet provides a means of calculating Present Value given a desired Future Value. The Interest Rate that governs growth can be changed. Same goes for the Future Value.

Remote Control using JavaScript

It is possible to set the Interest Rate and Future Value parameters. It is also possible to reset to initial values and show the 'About' information. It is also possible to get individual values for Interest Rate, Future Value and Present Value as well as a full listing of all relevant values.

Examples

Set Interest Rate to 23%

Set Future Value to 2000

Reset Applet

Show 'About' dialog

Show sample values

Show applet status

How to Invoke the Applet

The applet can be invoked by embedding an APPLET tag into your HTML document (if you look at the source of this document you will see a working example you can copy). The table below details the basic parameters used and additional startup parameters that are specific to this applet.

<APPLET 
  CODEBASE="../../../../classes"
  ALT="Present Value"
  CODE="applet.capdm.finance.presentvalue.PresentValueApp" 
  NAME="PresentValue"
  WIDTH="400"
  HEIGHT="500">
</APPLET>
Basic Parameters Use
CODEBASE="../../../../classes" The CODEBASE of the applet must point at the top-level classes directory in order for the applet to be found.
CODE="applet.capdm.finance.
presentvalue.PresentValueApp "
This required attribute gives the name of the file that contains the applet's compiled Applet subclass. This file is relative to the base URI of the applet.
ALT="Present Value" This optional attribute specifies any text that should be displayed if the browser understands the APPLET tag but can't run Java applets.
NAME="PresentValue" This optional attribute specifies a name for the applet instance, which makes it possible for applets on the same page to find (and communicate with) each other. If you intend to use JavaScript/Applet scripting then the applet must be named as shown.
WIDTH="400" HEIGHT="500" These required attributes give the initial width and height (in pixels) of the applet display area, not counting any windows or dialogs that the applet brings up.
Applet Startup Parameters Use
"NumberOfPeriods" The number of periods to show - default is 20.
"InterestRate" Starting Interest Rate - default is 10.0.
"FutureValue" Starting Future Value - default is 1000

For more information on the use of the APPLET tag and other attributes you can use but which are not listed above, visit the W3.org specification page at: APPLET tag in HTML 4.

Runtime Applet API Calls

This applet can be called into using Javascript 1.1 while running. Although JavaScript can call the Applet directly, some convenient JavaScript functions have been created which deal with the details of the communication. The following table lists the call Names which can be made, and gives examples of their use and results.

API Call Name Parameters Use and Result
setValue("InterestRate",value) "InterestRate" and value javascript:setValue("InterestRate",20); Changes the Interest Rate to 20%
setValue("FutureValue",value) "FutureValue" and value javascript:setValue("FutureValue",2000); Changes the Future Value to 2000
showAbout() none javascript:showAbout(); Shows the version dialog box of this applet.
reset() none javascript:reset(); resets the applet to initial starting position
getValue() none javascript:getValue(); Gets the status of the applet
getValue(name) 'name' can be one of "InterestRate", "FutureValue" or "PresentValue" javascript:getValue("InterestRate"); Gets the current Interest Rate as a string - eg "10.0". Other examples: javascript:getValue("FutureValue"); might return "2300"
javascript:getValue("PresentValue"); might return "120.3425"
getValue(name,dp) 'name' can be one of "InterestRate", "FutureValue" or "PresentValue"
'dp' is the number of decimal places of accuracy required
javascript:getValue("PresentValue",2); Gets the current Present Value as a string to 2 decimal places - a returned result might be "120.34"