123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- String answer = "";
-
- for(int i = 1; i <= 5; i++){
-
- for(int j = 1; j <= 5; j++){
-
- int multiply = i * j;
-
- String xString = String.valueOf(multiply);
-
- answer = answer.concat(String.format("%3s |", xString));
-
- }
- answer = answer.concat("\n");
- }
- return answer;
-
- }
-
- public static String getLargeMultiplicationTable() {
- String answer = "";
-
- for(int i = 1; i <= 10; i++){
-
- for(int j = 1; j <= 10; j++){
-
- int multiply = i * j;
-
- String xString = String.valueOf(multiply);
-
- answer = answer.concat(String.format("%3s |", xString));
-
- }
- answer = answer.concat("\n");
- }
- return answer;
-
- }
-
- public static String getMultiplicationTable(int tableSize) {
- String answer = "";
- for(int i = 1; i <= tableSize; i++){
-
- for(int j = 1; j <= tableSize; j++){
-
- int multiply = i * j;
-
- String xString = String.valueOf(multiply);
-
- answer = answer.concat(String.format("%3s |", xString));
-
- }
- answer = answer.concat("\n");
- }
- return answer;
-
- }
- }
-
|