12345678910111213141516171819202122232425262728293031323334353637 |
-
- public class TableUtilities {
- public static String getSmallMultiplicationTable() {
- StringBuilder stuff = new StringBuilder();
- for(int i = 1; i<= 5 ; i++) {
- for(int j =1; j<=5; j++) {
- stuff.append(String.format("%3d |", j*i));
- }
- stuff.append("\n");
- }
- return stuff.toString();
- }
-
- public static String getLargeMultiplicationTable() {
- StringBuilder word = new StringBuilder();
- for(int i = 1; i<=10; i++){
- for(int j = 1; j<=10;j++){
- word.append(String.format("%3d |", i*j));
- }
- word.append("\n");
- }
- return word.toString();
- }
-
- public static String getMultiplicationTable(int tableSize) {
- StringBuilder stuff = new StringBuilder();
- for (int i = 1; i<=tableSize; i++) {
- for (int j=1; j<=tableSize; j++) {
- stuff.append(String.format("%3d |", i*j));
-
- }
- stuff.append("\n");
- }
- return stuff.toString();
- }
- }
|