浏览代码

git git git

Owen Murphy 6 年前
父节点
当前提交
323448a3be
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15
    2
      src/main/java/io/zipcoder/microlabs/mastering_loops/TableUtilities.java

+ 15
- 2
src/main/java/io/zipcoder/microlabs/mastering_loops/TableUtilities.java 查看文件

@@ -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