1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
-
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- String multTable = "";
- int sum;
-
- for (int j = 1; j <= 5; j++){
- for (int i = 1; i <= 5; i++){
-
- multTable += String.format("%3d |", i*j);
-
- }
-
- multTable += "\n";
- }
- System.out.print(multTable);
- return multTable;
- }
-
- public static String getLargeMultiplicationTable() {
- String multTable = "";
-
- for (int j = 1; j <= 10; j++){
- for (int i = 1; i <= 10; i++){
-
- multTable += String.format("%3d |", i*j);
-
- }
-
- multTable += "\n";
- }
- System.out.print(multTable);
- return multTable;
- }
-
- public static String getMultiplicationTable(int tableSize) {
- String multTable = "";
-
- for (int j = 1; j <= tableSize; j++){
- for (int i = 1; i <= tableSize; i++){
-
- multTable += String.format("%3d |", i*j);
-
- }
-
- multTable += "\n";
- }
- System.out.print(multTable);
- return multTable;
- }
- }
|