1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- StringBuilder builder = new StringBuilder();
-
- for (int i = 1; i <= 4; i++) {
- for (int j =1; j <= 4; j++) {
-
- String value = String.format("%3d |", i * j);
- builder.append(value);
- }
- builder.append("\n");
-
- }
- return builder.toString();
- }
-
- public static String getLargeMultiplicationTable() {
- StringBuilder builder = new StringBuilder();
-
- for (int i = 1; i <= 9; i++) {
- for (int j =1; j <= 9; j++) {
-
- String value = String.format("%3d |", i * j);
- builder.append(value);
- }
- builder.append("\n");
-
- }
- return builder.toString();
-
-
- }
-
- public static String getMultiplicationTable(int tableSize) {
- StringBuilder builder = new StringBuilder();
-
- for (int i = 1; i <= tableSize; i++) {
- for (int j =1; j <= tableSize; j++) {
-
- String value = String.format("%3d |", i * j);
- builder.append(value);
- }
- builder.append("\n");
-
- }
- return builder.toString();
- }
- }
|