Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Done #61

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,28 +1,62 @@
package io.zipcoder.microlabs.mastering_loops;


import java.util.Arrays;

public class NumberUtilities {
public static String getEvenNumbers(int start, int stop) {
return null;
StringBuilder evenN = new StringBuilder();

for (int i = start; i < stop; i++) {
if ((i % 2) == 0) {
evenN.append(i);
}

}return evenN.toString();
}


public static String getOddNumbers(int start, int stop) {
return null;
}
StringBuilder newStringy = new StringBuilder();

for (int i = start; i < stop; i++) {
if ((i % 2) != 0) {
newStringy.append(i);
}

public static String getSquareNumbers(int start, int stop, int step) {
return null;
}
}return newStringy.toString();
}


public static String getSquareNumbers ( int start, int stop, int step){
StringBuilder newSt = new StringBuilder();

for (int i = start; i < stop; i += step) {
int squareD = (int) Math.pow(i, 2);
newSt.append(squareD);
}
return newSt.toString();
}


public static String getRange ( int start, int stop, int step){
StringBuilder newArr = new StringBuilder();

for (int i = start; i < stop; i += step) {
newArr.append(i);
}
return newArr.toString();
}


public static String getRange(int start, int stop, int step) {
return null;
}

public static String getExponentiationNumbers( int start, int stop, int step, int exponent){
StringBuilder expoS = new StringBuilder();

public static String getExponentiations(int start, int stop, int step, int exponent) {
return null;
for(int i = start; i < stop; i+= step){
int powerS = (int) Math.pow(i, exponent);
expoS.append(powerS);
}
return expoS.toString();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
package io.zipcoder.microlabs.mastering_loops;

public class TableUtilities {

public static String getSmallMultiplicationTable() {
return null;
String table = getMultiplicationTable(5);
return table;
}

public static String getLargeMultiplicationTable() {
return null;
String largeTable = getMultiplicationTable(10);
return largeTable;
}

public static String getMultiplicationTable(int tableSize) {
return null;
StringBuilder newTable = new StringBuilder();

for (int i = 1; i <= tableSize; i++) {
for (int m = 1; m <= tableSize; m++) {
newTable.append((String.format("%3d |", i * m)) + "");
}
newTable.append("" + "\n");
}
return newTable.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,46 @@
public class TriangleUtilities {

public static String getTriangle(int numberOfRows) {
return null;
StringBuilder newTri = new StringBuilder();

for (int i = 1; i < numberOfRows; i++) {
for (int m = 0; m < i; m++) {
newTri.append("*");
}
newTri.append("\n");
}
return newTri.toString();
}

public static String getRow(int numberOfStars) {
return null;
String newRow = "";
for (int i = 0; i < numberOfStars; i++) {
newRow += "*";
}
return newRow;
}

public static String getSmallTriangle() {
return null;
StringBuilder smallTri = new StringBuilder();
for (int i = 1; i <= 4; i++) {
for (int m = 0; m < i; m++) {
smallTri.append("*");
}
smallTri.append("\n");
}
return smallTri.toString();
}

public static String getLargeTriangle() {
return null;

public static String getLargeTriangle () {
StringBuilder largeTri = new StringBuilder();
for(int i = 1; i <= 9; i++){
for(int m = 0; m < i; m++){
largeTri.append("*");
}
largeTri.append("\n");
}
return largeTri.toString();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,10 @@ public void testGetRange2() {
}














@Test
public void testGetEvenNumbers() {
// : Given
String expected = "5791113151719";
String expected = "681012141618";
int start = 5;
int stop = 20;

Expand All @@ -65,7 +53,7 @@ public void testGetEvenNumbers() {
@Test
public void testGetOddNumbers() {
// : Given
String expected = "681012141618";
String expected = "5791113151719";
int start = 5;
int stop = 20;
int step = 5;
Expand All @@ -78,7 +66,6 @@ public void testGetOddNumbers() {
}



@Test
public void testGetSquareNumbers() {
// : Given
Expand All @@ -105,7 +92,7 @@ public void testGetExponentiationNumbers() {
int exponent = 2;

// : When
String actual = NumberUtilities.getExponentiations(start, stop, step, exponent);
String actual = NumberUtilities.getExponentiationNumbers(start, stop, step, exponent);

Assert.assertEquals(expected, actual);
}
Expand Down