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

Please accept this, I must sleep #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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;

StringBuilder square = new StringBuilder();
for (int i = start; i < stop; i += step) {
int squaredNum = (int) Math.pow(i, 2);
square.append(squaredNum);
}
return square.toString();
}
public static String getRange ( int start, int stop, int step){

StringBuilder range = new StringBuilder();

public static String getRange(int start, int stop, int step) {
return null;
}
for (int i = start; i < stop; i += step) {

range.append(i);
}
return range.toString();
}

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

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

for (int i = start; i < stop; i+= step) {

int exponVar = exponent;

int startExpon = (int) Math.pow(i, exponVar);

expon.append(startExpon);
}
return expon.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,43 @@

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

StringBuilder matrix = new StringBuilder();

for (int row = 1; row <= 5; row++) {
for (int column = 1; column <= 5; column++) {
matrix.append(String.format("%3d |", row * column));
}
matrix.append("\n");
}

return matrix.toString();
}

public static String getLargeMultiplicationTable() {
return null;

StringBuilder matrix = new StringBuilder();

for (int row = 1; row <= 10; row++) {
for (int column = 1; column <= 10; column++) {
matrix.append(String.format("%3d |", row * column));
}
matrix.append("\n");
}

return matrix.toString();
}

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

for (int row = 1; row <= 20; row++) {
for (int column = 1; column <= 20; column++) {
matrix.append(String.format("%3d |", row * column));
}
matrix.append("\n");
}

return matrix.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,51 @@
public class TriangleUtilities {

public static String getTriangle(int numberOfRows) {
return null;

String triangle = "";
for(int i=1; i <numberOfRows; i++)
{
for(int j=0; j < i; j++){
triangle+= "*";
}triangle+= "\n";

}
return triangle;
}

public static String getRow(int numberOfStars) {
return null;
}

String output = "";
for (int i = 0; i < numberOfStars; i++) {
output += "*";
}
return output;
}


public static String getSmallTriangle() {
return null;

String triangle = "";
for(int i=1; i <=4; i++)
{
for(int j=0; j < i; j++){
triangle+= "*";
}triangle+= "\n";

}
return triangle;

}

public static String getLargeTriangle() {
return null;
String triangle = "";
for(int i=1; i <=9; i++)
{
for(int j=0; j < i; j++){
triangle+= "*";
}triangle+= "\n";

}
return triangle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testGetRange2() {
@Test
public void testGetEvenNumbers() {
// : Given
String expected = "5791113151719";
String expected = "68101214161820";
int start = 5;
int stop = 20;

Expand All @@ -65,7 +65,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 Down