12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
-
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- String str = "", strA = "";
- int multiply = 1;
- for(int i = 0; i < 5; i++)
- {
- for(int x = 1; x < 6; x++)
- {
- strA = strA.concat(String.format("%3d |", (x * multiply) ));
- }
- str = str.concat(strA + "\n");
- strA = "";
- multiply++;
- }
- return str;
- }
-
- public static String getLargeMultiplicationTable() {
- String str = "", strA = "";
- int multiply = 1;
- for(int i = 0; i < 10; i++)
- {
- for(int x = 1; x < 11; x++)
- {
- strA = strA.concat(String.format("%3d |", (x * multiply) ));
- }
- str = str.concat(strA + "\n");
- strA = "";
- multiply++;
- }
- return str;
- }
-
- public static String getMultiplicationTable(int tableSize) {
- String str = "", strA = "";
- int multiply = 1;
- for(int i = 0; i < tableSize; i++)
- {
- for(int x = 1; x <= tableSize; x++)
- {
- strA = strA.concat(String.format("%3d |", (x * multiply) ));
- }
- str = str.concat(strA + "\n");
- strA = "";
- multiply++;
- }
- return str;
- }
- }
|