123456789101112131415161718192021222324252627 |
-
- public class TableUtilities {
-
-
- public static String getSmallMultiplicationTable() {
-
- return getMultiplicationTable(5);
- }
-
- public static String getLargeMultiplicationTable() {
- return getMultiplicationTable(10);
- }
-
- public static String getMultiplicationTable(int tableSize) {
-
- StringBuilder sb = new StringBuilder();
- //int tableSize = 5;
- for(int i = 1; i <= tableSize; i++) {
- for(int j = 1; j <= tableSize; j++) {
- sb.append(String.format("%3d |", i * j));
- }sb.append("\n");
- }
- return sb.toString();
- }
- }
-
|