This is what I'm trying to do:Write a static void method called printAdditionTable that prints a two dimensional addition table for the numbers 0 to 12. Use a helper method that takes an integer parameter and prints one row of the table to demonstrate your knowledge of encapsulation. Use for loops in your methods.
public static void printAdditionTable (int i) { int tablenum = i; int rows; for (rows = 0; rows<=12; ++rows) { int columns; for (columns = 0; columns<=12; columns++) { System.out.print (tablenum + " "); tablenum+=1; if (columns==12) { tablenum = rows; System.out.println(); } } } }
The problems are that the first row is repeated and the numbers do not stop at 12 for the rest of the rows.
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11 12 13
2 3 4 5 6 7 8 9 10 11 12 13 14
3 4 5 6 7 8 9 10 11 12 13 14 15
4 5 6 7 8 9 10 11 12 13 14 15 16
5 6 7 8 9 10 11 12 13 14 15 16 17
6 7 8 9 10 11 12 13 14 15 16 17 18
7 8 9 10 11 12 13 14 15 16 17 18 19
8 9 10 11 12 13 14 15 16 17 18 19 20
9 10 11 12 13 14 15 16 17 18 19 20 21
10 11 12 13 14 15 16 17 18 19 20 21 22
11 12 13 14 15 16 17 18 19 20 21 22 23