// Fig. 3.6: Interest.java
// Calculating compound interest
import java.awt.Graphics;
import java.applet.Applet;

public class Interest extends Applet {
   public void paint( Graphics g )
   {
	double principal = 1000.0, amount = principal;
	double rate = .05, ratePlus1 = 1 + rate;
      	int yPos = 40;

	g.drawString( "Year", 25, 25 );
	g.drawString( "Amount on deposit", 100, 25 );
 
      for ( int year = 1; year <= 10; year++, yPos += 15 ) {
	amount *= ratePlus1;
	g.drawString( Integer.toString( year ), 25, yPos );
	g.drawString( Double.toString( amount ), 100, yPos );
      }
   }
}