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