123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
-
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable()
- {
- String str= "";
- for (int i=1; i<=5; i++)
- {
- int result=0;
- for(int j=1; j<=5; j++)
- {
- result = i*j;
-
- str += String.format("%3d |",result);
-
- }
- str += "\n";
- }
- return str;
- }
-
-
- public static String getLargeMultiplicationTable() {
- String str= "";
- for (int i=1; i<=10; i++)
- {
- int result=0;
- for(int j=1; j<=10; j++)
- {
- result = i*j;
-
- str += String.format("%3d |",result);
-
- }
- str += "\n";
- }
- return str;
- }
-
- public static String getMultiplicationTable(int tableSize) {
- String str= "";
- for (int i=1; i<=tableSize; i++)
- {
- int result=0;
- for(int j=1; j<=tableSize; j++)
- {
- result = i*j;
-
- str += String.format("%3d |",result);
-
- }
- str += "\n";
- }
- return str;
- }
- }
|