Owen Murphy 6 vuotta sitten
vanhempi
commit
323448a3be

+ 15
- 2
src/main/java/io/zipcoder/microlabs/mastering_loops/TableUtilities.java Näytä tiedosto

@@ -2,9 +2,22 @@ package io.zipcoder.microlabs.mastering_loops;
2 2
 
3 3
 public class TableUtilities {
4 4
     public static String getSmallMultiplicationTable() {
5
-        return null;
6
-    }
5
+        StringBuilder smt = new StringBuilder();
6
+
7
+        for (int i = 1; i <= 5; i++) {
8
+            for (int j = 1; j <= 5; j++) {
9
+
10
+                int num = i * j;
11
+
12
+                smt.append(String.format("%3d |", num));
7 13
 
14
+            }
15
+            smt.append("\n");
16
+
17
+        }
18
+        String myTable = smt.toString();
19
+        return myTable;
20
+    }
8 21
 
9 22
     public static String getLargeMultiplicationTable() {
10 23