CAPDM Tutorial Applets

Stacked Investments

Functionality:

This applet demonstrates how a company decides on how much to invest.

The applet allows the student to see how varying the amount invested and the amounts returned from investments changes the present wealth. The interest rate can also be varied to show how the slopes of the 2 white lines vary.

Note that the initial parameters are fixed. At t0 the student has $1000, and expects to receive $1540 at t1. The CF0 axis represents the cash flow available now (t0), and the CF1 axis represents the cash flow available later (t1). The inside white line represents doing no investing with the money. The slope of the line represents the market interest rate.

The outside white line represents choosing the best investments, and shows how wise investing can increase the Net Present Value of the student.

Remote Control using JavaScript

It is possible to set the independent variable values in the applet and return strings representing individual values or the status of the applet (ie all independent variable values).

Examples

Show 'About' dialog

Reset Applet

Show applet status

Set Interest Rate to 14%

Set Investment in A to 550.5

Set Expected Return D to 750

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="Stacked Investments"
  CODE="applet.capdm.finance.stackedinvestments.StackedInvestmentsApp"
  NAME="Stacked Investments"
  WIDTH="400"
  HEIGHT="550">
</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.
stackedinvestments.StackedInvestmentsApp"
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="Stacked Investments" This optional attribute specifies any text that should be displayed if the browser understands the APPLET tag but can't run Java applets.
NAME="StackedInvestments" 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 a shown.
WIDTH="400" HEIGHT="550" 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
There are no applet-specific startup parameters.

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(name,value) 'name' can be one of "InterestRate",
"InvestA", "InvestB", "InvestC", "InvestD", "ReturnA", "ReturnB", "ReturnC", "ReturnD"
'value' is its new value

eg. javascript:document.StackedInvestments.setValue('InterestRate','14');

Used to set the value of an independent variable in the applet

getValue() none javascript:document.StackedInvestments.getValue(); Gets the status of the applet
getValue(name)

'name' can be one of "InterestRate",
"InvestA", "InvestB", "InvestC", "InvestD", "ReturnA", "ReturnB", "ReturnC", "ReturnD".

eg. javascript:document.StackedInvestments.getValue('InterestRate');

Returns the current value of the variable from the applet.

getValue(name,dp) 'name' can be one of "InterestRate",
"InvestA", "InvestB", "InvestC", "InvestD", "ReturnA", "ReturnB", "ReturnC", "ReturnD"
'dp' is the number of decimal places of accuracy required
javascript:document.StackedInvestmnts.getValue("InterestRate",2); Gets the current value of the variable as a string to the number of decimal places specified
showAbout() none javascript:showAbout(); Shows the version dialog box of this applet.
reset() none javascript:reset(); resets the applet to initial starting position