diff --git a/NumberUtilities.java b/NumberUtilities.java index 1d5ba50..735f7af 100644 --- a/NumberUtilities.java +++ b/NumberUtilities.java @@ -4,29 +4,58 @@ public class NumberUtilities { public static String getRange(int stop) { - return null; + String rangeString = ""; + for (int i = 0; i < stop; i++){ + rangeString += i; + } + return rangeString; } public static String getRange(int start, int stop) { - return null; + String rangeString = ""; + for (int i = start; i < stop; i++){ + rangeString += i; + } + return rangeString; } public static String getRange(int start, int stop, int step) { - return null; + String rangeString = ""; + for (int i = start; i < stop; i+=step){ + rangeString += i; + } + return rangeString; } public static String getEvenNumbers(int start, int stop) { - return null; + String evenNumbers = ""; + for (int i = start; i < stop; i++){ + if (i % 2 == 0){ + evenNumbers +=i; + } + } + return evenNumbers; } public static String getOddNumbers(int start, int stop) { - return null; + String oddNumbers = ""; + for (int i = start; i < stop; i++){ + if (i % 2 == 1){ + oddNumbers +=i; + } + } + return oddNumbers; } public static String getExponentiations(int start, int stop, int exponent) { - return null; + String exNumbers = ""; + for (int i = start; i <= stop; i++){ + exNumbers += (int)Math.pow(i,exponent); + } + + return exNumbers; } } diff --git a/TableUtilities.java b/TableUtilities.java index 03bf004..417f519 100644 --- a/TableUtilities.java +++ b/TableUtilities.java @@ -2,14 +2,29 @@ public class TableUtilities { public static String getSmallMultiplicationTable() { - return null; - } + String multTable = ""; + for (int i = 1; i <=5; i++){ + for (int j = 1; j <= 5; j++){ + multTable += String.format("%3d |", i*j); + } multTable += "\n"; +}return multTable; +} public static String getLargeMultiplicationTable() { - return null; + String multTable = ""; + for (int i = 1; i <=10; i++){ + for (int j = 1; j <= 10; j++){ + multTable += String.format("%3d |", i*j); + } multTable += "\n"; +}return multTable; } public static String getMultiplicationTable(int tableSize) { - return null; + String multTable = ""; + for (int i = 1; i <=tableSize; i++){ + for (int j = 1; j <= tableSize; j++){ + multTable += String.format("%3d |", i*j); + } multTable += "\n"; +}return multTable; } } diff --git a/TriangleUtilities.java b/TriangleUtilities.java index 8755fd0..1ad0486 100644 --- a/TriangleUtilities.java +++ b/TriangleUtilities.java @@ -3,19 +3,45 @@ public class TriangleUtilities { public static String getRow(int numberOfStars) { - return null; - } - + String rowYaBoat = ""; + for(int i = 0; i < numberOfStars; i++){ + rowYaBoat += "*"; + } + return rowYaBoat; +} + public static String getTriangle(int numberOfRows) { - return null; + String rowYaBoat = ""; + for(int i = 0; i < numberOfRows; i++){ + for (int j = 0; j <= i; j++){ + rowYaBoat += "*"; + } + rowYaBoat += "\n"; +} + return rowYaBoat; + } public static String getSmallTriangle() { - return null; + String rowYaBoat = ""; + for(int i = 0; i < 4; i++){ + for (int j = 0; j <= i; j++){ + rowYaBoat += "*"; + } + rowYaBoat += "\n"; +} + return rowYaBoat; } public static String getLargeTriangle() { - return null; + String rowYaBoat = ""; + for(int i = 0; i < 9; i++){ + for (int j = 0; j <= i; j++){ + rowYaBoat += "*"; + } + rowYaBoat += "\n"; +} + return rowYaBoat; } }