FileDocCategorySizeDatePackage
Interest.javaAPI DocExample716Thu Sep 28 13:28:54 BST 2000None

Interest

public class Interest extends Applet

Fields Summary
Constructors Summary
Methods Summary
public voidpaint(java.awt.Graphics g)

      String input;
      double interest_rate = 0.0;
      
      // Rate for a bank loan
      interest_rate = 0.07;
      double pounds = 1000.0;  // Sum borrowed or deposited...
      int    years  = 10;      // Number of years...
      double    sum = 0.0;     // Accumulated sum...
      g.drawString("Year       Amount borrowed", 20, 40);
      for(int year = 1; year <= years; year++)
      {
         sum = pounds * Math.pow(1.0 + interest_rate,year);
	      g.drawString(year + "             " + (int)sum, 20, (year+2)* 20);
      }