// Invest2.java
// by BRP

import javax.swing.*;

public class Invest2 extends JApplet
{
	public void init()
	{
		double monthly = 250;
		double rate = .09;
		int years = 20;
		double balance = 0;

		// for every month in "years"
		for (int months = 0; months < years*12 ; months++ )
		{

			// add interest to balance
			balance *= 1 + rate/12;
			// add this monthly investment
			balance += monthly;

		}

		// show the final balance
		JOptionPane.showMessageDialog(null,
			"Investing $" + monthly + " per month at \n" +
			rate + "% annual return for " + years + " years,\n" +
			"You'll end up with about $" + balance);

	}
}


