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