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