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