12345678910111213141516171819202122232425262728293031323334353637383940414243 |
-
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- StringBuilder timesTable = new StringBuilder();
- int x;
- int y;
- for (x = 1; x <= 5; x++){
- for (y = 1; y <= 5; y++){
- timesTable.append(String.format("%3d |", x*y));
- }
- timesTable.append("\n");
- }
- return timesTable.toString();
- }
-
- public static String getLargeMultiplicationTable() {
- StringBuilder timesTable = new StringBuilder();
- int x;
- int y;
- for (x = 1; x <= 10; x++){
- for (y = 1; y <= 10; y++){
- timesTable.append(String.format("%3d |", x*y));
- }
- timesTable.append("\n");
- }
- return timesTable.toString();
- }
-
- public static String getMultiplicationTable(int tableSize) {
- StringBuilder timesTable = new StringBuilder();
- int x;
- int y;
- for (x = 1; x <= tableSize; x++){
- for (y = 1; y <= tableSize; y++){
- timesTable.append(String.format("%3d |", x*y));
- }
- timesTable.append("\n");
- }
- return timesTable.toString();
- }
- }
|