123456789101112131415161718192021222324252627282930313233343536373839404142 |
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- String fin = "";
- int step = 1;
- for(int i = 1; i <= 5; i++) {
- for(int j = i; j <= (5*step); j+=step){
- fin = fin.concat(String.format("%4s|", j + " "));
- }
- step+=1;
- fin += "\n";
- }
- return fin;
- }
-
- public static String getLargeMultiplicationTable() {
- String fin = "";
- int step = 1;
- for(int i = 1; i <= 10; i++) {
- for(int j = i; j <= (10*step); j+=step){
- fin = fin.concat(String.format("%4s|", j + " "));
- }
- step+=1;
- fin += "\n";
- }
- return fin;
- }
-
- public static String getMultiplicationTable(int tableSize) {
- String fin = "";
- int step = 1;
- for(int i = 1; i <= tableSize; i++) {
- for(int j = i; j <= (tableSize*step); j+=step){
- fin = fin.concat(String.format("%4s|", j + " "));
- }
- step+=1;
- fin += "\n";
- }
- return fin;
- }
- }
|