img
FIGURE 32-5
The MaxWD
applet
$500,000 in a retirement account, how much can you take out each month for 20 years, assuming
a 6 percent rate of return? The formula that computes the maximum withdrawal is shown here:
Maximum Withdrawal = principal * ( ( (rateOfRet / wdPerYear) /
(­1 + ((rateOfRet / wdPerYear) + 1)  wdPerYear * numYears) ) +
(rateOfRet / wdPerYear) )
where rateOfRet specifies the rate of return, principal contains the value of the initial
investment, wdPerYear specifies the number of withdrawals per year, and numYears
specifies the length of the annuity in years.
The MaxWD applet shown next computes the maximum periodic withdrawals that can
be made over a specified length of time for an assumed rate of return. The applet produced
by this program is shown in Figure 32-5.
/* Compute the maximum annuity that can
be withdrawn from an investment over
a period of time.  */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
/*
<applet code="MaxWD" width=340 height=260>
</applet>
*/
public class MaxWD extends JApplet
implements ActionListener {
JTextField maxWDText, orgPText, periodText,
rateText, numWDText;
JButton doIt;
double principal;
//
initial principal
double rateOfRet;
//
annual rate of return
double numYears;
//
length of time in years
int numPerYear;
//
number of withdrawals per year
NumberFormat nf;
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home