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

well #65

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

well #65

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,34 +3,94 @@

public class NumberUtilities {
public static String getEvenNumbers(int start, int stop) {
return null;
StringBuilder even = new StringBuilder();
for (int i = start; i < stop; i++) {
if (i % 2 != 0) {
even.append(i);
}

}
return even.toString();
}


public static String getOddNumbers(int start, int stop) {
return null;
}
StringBuilder odd = new StringBuilder();
for (int i = start; i < stop; i++) {
if (i % 2 == 0) {
odd.append(i);
}

}
return odd.toString();


}

public static String getSquareNumbers(int start, int stop, int step) {
return null;
StringBuilder squared = new StringBuilder();
for (int i = start; i < stop; i += step) {

squared.append(i * i);


}

return squared.toString();

}

public static String getRange(int start) {
return null;
public static String getRange(int stop) {
StringBuilder range1 = new StringBuilder();
for (int i =0; i < stop; i++) {

range1.append(i);


}
return range1.toString();




}

public static String getRange(int start, int stop) {
return null;
StringBuilder range = new StringBuilder();
for (int i = start; i < stop; i++) {

range.append(i);


}
return range.toString();



}


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

rangeNum.append(i);


}
return rangeNum.toString();

}


public static String getExponentiations(int start, int stop, int step, int exponent) {
return null;
StringBuilder old = new StringBuilder();
for (int i = start; i < stop; i += step) {

old.append(i * i);
}
return old.toString();
}
}


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

import com.sun.javafx.binding.StringFormatter;

public class TableUtilities {
public static String getSmallMultiplicationTable() {
return null;
StringBuilder smallMulti = new StringBuilder();
for (int h = 1; h <6; h++){
for (int w=1; w <6; w++){
smallMulti.append(String.format("%3d |", w*h));
}
smallMulti.append("\n");
}

return smallMulti.toString();
}

public static String getLargeMultiplicationTable() {
return null;
StringBuilder multi = new StringBuilder();
for (int h =1; h < 11; h++){
for (int w =1; w <11; w++){
multi.append(String.format("%3d |", w*h));

}
multi.append("\n");
}
return multi.toString();

}

public static String getMultiplicationTable(int tableSize) {
return null;
StringBuilder multiTable = new StringBuilder();
for (int h =1; h < 21; h++){
for (int w =1; w <21; w++){
multiTable.append(String.format("%3d |", w*h));

}
multiTable.append("\n");
}
return multiTable.toString();

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

public static String getTriangle(int numberOfRows) {
return null;
StringBuilder triangle = new StringBuilder();
for (int row =1; row <numberOfRows; row++)
{
for (int column =0;column < row; column++)
{
triangle.append("*");
}
triangle.append("\n");
}
return triangle.toString();
}





public static String getRow(int numberOfStars) {
return null;
StringBuilder row = new StringBuilder();
for (int w=1; w < 21; w++){

row.append("*");


}
return row.toString();


}

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

public static String getLargeTriangle() {
return null;

StringBuilder largeTriangle = new StringBuilder();
for (int row =1; row <10; row++)
{
for (int column =0;column < row; column++)
{
largeTriangle.append("*");
}
largeTriangle.append("\n");
}
return largeTriangle.toString();
}

}

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class NumberUtilitiesTest {
public void testGetRange1A() {
// : Given
String expected = "0123456789";
int stop = 11;
int stop = 10;

// : When
String actual = NumberUtilities.getRange(stop);
Expand Down Expand Up @@ -87,7 +87,7 @@ public void testGetRange2B() {
@Test
public void testGetRange3B() {
// : Given
String expected = "100101103104105106107108109";
String expected = "100101102103104105106107108109";
int start = 100;
int stop = 110;

Expand Down