Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

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
Expand Up @@ -3,26 +3,60 @@

public class NumberUtilities {
public static String getEvenNumbers(int start, int stop) {
return null;
String even = "";
for (int x = start; x <=stop; x++) {
if (x % 2 == 0) {
even += Integer.toString(x);
}
}

return even;
}


public static String getOddNumbers(int start, int stop) {
return null;
String odd = "";
for (int x = start; x <=stop; x++) {
if (x % 2 != 0) {
odd += Integer.toString(x);
}
}

return odd;
}


public static String getSquareNumbers(int start, int stop, int step) {
return null;
String sqrt = "";

for(int x = start; x <= stop; x+=step ) {
int num = x * x;
sqrt += Integer.toString(num);

}

return sqrt;
}


public static String getRange(int start, int stop, int step) {
return null;
String range = "";
for (int x = start; x <=stop; x += step) {
range += Integer.toString(x);
}
return range;
}


public static String getExponentiations(int start, int stop, int step, int exponent) {
return null;
String expo = "";

for(int x = start; x < stop; x+=step ) {
int num = (int) Math.pow(x,exponent);
expo += Integer.toString(num);

}

return expo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,51 @@

public class TableUtilities {
public static String getSmallMultiplicationTable() {
return null;

StringBuilder sm = new StringBuilder();

for (int x = 1; x <= 5; x++) {
for(int y = 1; y <= 5; y++) {

sm.append(String.format("%3d |", x * y));
}
sm.append("\n");
}


return sm.toString();
}

public static String getLargeMultiplicationTable() {
return null;
StringBuilder sm = new StringBuilder();

for (int x = 1; x <= 10; x++) {
for(int y = 1; y <= 10; y++) {

sm.append(String.format("%3d |", x * y));
}
sm.append("\n");
}


return sm.toString();
}



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

for (int x = 1; x <= tableSize; x++) {
for(int y = 1; y <= tableSize; y++) {

sm.append(String.format("%3d |", x * y));
}
sm.append("\n");
}


return sm.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 sm = new StringBuilder();

for (int x = 1; x < numberOfRows; x++) {
for (int j = 0; j < x; j++) {
sm.append("*");
}
sm.append("\n");
}
return sm.toString();
}

public static String getRow(int numberOfStars) {
return null;
StringBuilder sm = new StringBuilder();

for (int x = 0; x < numberOfStars; x++) {
sm.append("*");
}

return sm.toString();
}

public static String getSmallTriangle() {
return null;
StringBuilder sm = new StringBuilder();
for (int x = 1; x <= 5; x++) {
for (int j = 0; j < x; j++) {
sm.append("*");
}
sm.append("\n");
}
return sm.toString();
}

public static String getLargeTriangle() {
return null;
StringBuilder sm = new StringBuilder();
for (int x = 1; x <= 9; x++) {
for (int j = 0; j < x; j++) {
sm.append("*");
}
sm.append("\n");
}
return sm.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class NumberUtilitiesTest {
@Test
public void testGetRange1() {
// : Given
String expected = "51015";
String expected = "5101520";
int start = 5;
int stop = 20;
int step = 5;
Expand All @@ -23,7 +23,7 @@ public void testGetRange1() {
@Test
public void testGetRange2() {
// : Given
String expected = "012345678910111213141516171819";
String expected = "01234567891011121314151617181920";
int start = 0;
int stop = 20;
int step = 1;
Expand Down Expand Up @@ -51,7 +51,8 @@ public void testGetRange2() {
@Test
public void testGetEvenNumbers() {
// : Given
String expected = "5791113151719";
// String expected = "5791113151719";
String expected = "68101214161820";
int start = 5;
int stop = 20;

Expand All @@ -65,7 +66,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 @@ -82,7 +83,7 @@ public void testGetOddNumbers() {
@Test
public void testGetSquareNumbers() {
// : Given
String expected = "25100225";
String expected = "25100225400";
int start = 5;
int stop = 20;
int step = 5;
Expand Down