// // P.534 // 2-D Arrays // public class InterestTable { public static void main(String[] args) { int[][] table = new int[10][6]; for(int row=0; row<10; row++) for(int col=0; col<6; col++) table[row][col] = getBalance(1000, row+1, (5+0.5*col)); System.out.println("Bal ...: "+"\n\n"); System.out.println("Years\t5.00%\t5.50%\t6.00%\t6.50%\t7.00%\t5.50%"); System.out.println("-----\t-----\t-----\t-----\t-----\t-----\t-----"); for(int row=0; row<10; row++) { System.out.print((row+1) + "\t"); for(int col=0; col<6; col++) System.out.print("$"+ table[row][col] + "\t"); System.out.println(); } System.out.println("\n\n\n\n\n"); } public static int getBalance(double startB, int years, double rate) { double runBal = startB; for(int count=1; count<=years; count++); runBal *= 1 + rate/100; return (int)Math.round(runBal); } }