1234567891011121314151617181920212223 |
-
-
- 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();
- for (int column =1; column <= tableSize; column++) {
- for (int row =1; row<=tableSize; row++){
- sb.append(String.format("%3d |", row * column));
- }
- sb.append("\n");
- }
- return sb.toString();
- }
- }
|