From 77c3af3183abe6ff176bf0116e5a9e3a23200a1e Mon Sep 17 00:00:00 2001 From: Jessica Campbell Date: Thu, 8 Feb 2018 13:47:31 -0500 Subject: [PATCH] Tri Guys --- .../mastering_loops/NumberUtilities.java | 44 +++++++++++++--- .../mastering_loops/TableUtilities.java | 40 +++++++++++++-- .../mastering_loops/TriangleUtilities.java | 50 +++++++++++++++++-- .../mastering_loops/NumberUtilitiesTest.java | 4 +- 4 files changed, 122 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/zipcoder/microlabs/mastering_loops/NumberUtilities.java b/src/main/java/io/zipcoder/microlabs/mastering_loops/NumberUtilities.java index 5a742c4..1243ee2 100644 --- a/src/main/java/io/zipcoder/microlabs/mastering_loops/NumberUtilities.java +++ b/src/main/java/io/zipcoder/microlabs/mastering_loops/NumberUtilities.java @@ -3,26 +3,56 @@ public class NumberUtilities { public static String getEvenNumbers(int start, int stop) { - return null; + StringBuilder evenString = new StringBuilder(); + if (start % 2 == 0) { + for (int i = start; i < stop; i++){ + evenString.append(i); + } + } + return evenString.toString(); } public static String getOddNumbers(int start, int stop) { - return null; + StringBuilder oddString = new StringBuilder(); + if (start % 2 == 1) { + for (int i = start; i < stop; i++){ + oddString.append(i); + } + } + return oddString.toString(); } public static String getSquareNumbers(int start, int stop, int step) { - return null; - } + StringBuilder squareString = new StringBuilder(); + + for (int i = start; i < stop; i++){ + squareString.append(i*i); + } + return squareString.toString(); + } + + public static String getRange(int start, int stop, int step) { - return null; - } + StringBuilder range = new StringBuilder(); + for (int i = start; i