Skip to content

Finally Complete #60

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

Open
wants to merge 2 commits 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 @@ -7,5 +7,7 @@
*/
public class MainApp {
public static void main(String[] args) {


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,68 @@

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

String outcome = "";

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

if (i % 2 == 0)
{

outcome += i;

}

}

return outcome;
}


public static String getOddNumbers(int start, int stop) {
return null;

String outcome = "";

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

{
if (i % 2 != 0)
{

outcome += i;

}
}


return outcome;
}


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

String outcome = "";

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

return outcome;
}


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

String outcome = "";

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

}

return outcome;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,74 @@
package io.zipcoder.microlabs.mastering_loops;

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

public class TableUtilities
{
public static String getSmallMultiplicationTable()
{
//stringBuilder are mutable/can be changed
StringBuilder smallMultiplicationTable = new StringBuilder();

for (int i = 1; i <= 5; i++)
{
for (int j = 1; j<= 5; j++)
{

int num = i * j;
smallMultiplicationTable.append(String.format("%3d |", num));

} smallMultiplicationTable.append("\n");


}

String myTable = smallMultiplicationTable.toString();
return myTable;



}

public static String getLargeMultiplicationTable() {
return null;

StringBuilder largeMultiplicationTable = new StringBuilder();

for (int i = 1; i <= 10; i++)
{

for (int j = 1; j <= 10; j++)
{
int num = i * j;
largeMultiplicationTable.append(String.format("%3d |", num));

} largeMultiplicationTable.append("\n");
}

String largeTable = largeMultiplicationTable.toString();
return largeTable;
}

public static String getMultiplicationTable(int tableSize) {
return null;



StringBuilder multiplicationTable = new StringBuilder();

for (int i = 1; i <= tableSize; i++){

for (int j = 1; j <= tableSize; j++){

int num = i * j;
multiplicationTable.append(String.format("%3d |", num));

} multiplicationTable.append(String.format("\n"));

}

String myTable = multiplicationTable.toString();
return myTable;


}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,38 @@
public class TriangleUtilities {

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

String triangle = "";

for (int i = 1; i < numberOfRows; i++){

triangle += TriangleUtilities.getRow(i) + "\n";
}

return triangle;
}

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

String row = "";

for (int i = 1; i <= numberOfStars; i++)
{
row += "*";

}

return row;
}

//
public static String getSmallTriangle() {
return null;

return getTriangle(5);
}

public static String getLargeTriangle() {
return null;

return getTriangle(10);
}
}
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 = "681012141618";
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