UNB/ CS/ David Bremner/ teaching/ java/ Matrix.java
import ccj.*;

public class Matrix
{  public static void main(String[] args)
   {  double[][] balances = new double[11][6];
      int i;
      int j;
      for (i = 0; i < balances.length; i++)
         for (j = 0; j < balances[i].length; j++)
            balances[i][j] = futureValue(10000, 5 + i * 0.5,
               5 + j * 5);

      printMatrix(balances);
   }

   public static double futureValue(double initialBalance,
      double p, int nyear)
   {  double b = initialBalance
         * Math.pow(1 + p / 12 / 100, 12 * nyear);
      return b;
   }

   public static void printMatrix(double[][] m)
   {  int i;
      for (i = 0; i < m.length; i++)
      {  int j;
         for (j = 0; j < m[i].length; j++)
            Console.out.printf("%10.2f", m[i][j]);
         Console.out.print("\n");
      }
   }
}