UNB/ CS/ David Bremner/ teaching/ java/ DoublInv.java
public class DoublInv
{  public static void main(String[] args)
   {  ConsoleReader console = new ConsoleReader(System.in);  

      System.out.println("Interest rate:");   
      double rate = console.readDouble();

      System.out.println("Initial balance:");   
      double initialBalance = console.readDouble();

      int year = 0;
      double balance = initialBalance;

      // keep accumulating interest until balance doubles
      
      while (balance < 2 * initialBalance)
      {  year++;
         double interest = balance * rate / 100;
         balance = balance + interest;
      }

      System.out.println("The investment doubled after "
         + year + " years.");
   }
}