12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
-
-
- 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 myString = String.valueOf(multiply);
- answer = answer.concat(String.format("%3s |", myString));
-
-
- }
- answer = answer.concat("\n");
- }
- System.out.println(answer);
- 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 myString = String.valueOf(multiply);
- answer = answer.concat(String.format("%3s |", myString));
-
-
- }
- answer = answer.concat("\n");
- }
- System.out.println(answer);
- 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 myString = String.valueOf(multiply);
- answer = answer.concat(String.format("%3s |", myString));
-
-
- }
- answer = answer.concat("\n");
- }
- System.out.println(answer);
- return answer;
- }
- }
|