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