Skip to content

Tryin those angles #48

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 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
@@ -1,28 +1,77 @@
package io.zipcoder.microlabs.mastering_loops;

import java.util.ArrayList;

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

StringBuilder evens = new StringBuilder();

while (start < stop) {
if (start % 2 == 0){
evens.append("" + start);
}
start++;
}

return evens.toString();
}


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

StringBuilder odds = new StringBuilder();

while (start < stop) {
if (start % 2 == 1){
odds.append("" + start);
}
start++;
}

return odds.toString();

}


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

StringBuilder sqNums = new StringBuilder();

for (int i = start; i < stop; i+= step){
sqNums.append((long)Math.pow(i , 2));
}

return sqNums.toString();

}


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

StringBuilder range = new StringBuilder();

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;

//int start = 5;
//int stop = 20;
//int step = 5;
//int exponent = 2;

StringBuilder expo = new StringBuilder();

for (int i = start; i < stop; i+= step){
expo.append((long)Math.pow(i , exponent));
}

return expo.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,45 @@

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

StringBuilder tree = new StringBuilder();

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

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

}

public static String getLargeMultiplicationTable() {
return null;

StringBuilder tree = new StringBuilder();

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

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

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

StringBuilder tree = new StringBuilder();

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

}
tree.append("\n");
}
return tree.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,56 @@
public class TriangleUtilities {

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

StringBuilder Tree = new StringBuilder();

for (int i = 1; i < numberOfRows; i++) {
for (int j = 0; j < i; j++) {
Tree.append("*");
}
Tree.append("\n");
}

return Tree.toString();

}

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

StringBuilder row = new StringBuilder();

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

return row.toString();
}

public static String getSmallTriangle() {
return null;

StringBuilder smallTree = new StringBuilder();

for (int i = 1; i < 5; i++) {
for (int j = 0; j < i; j++) {
smallTree.append("*");
}
smallTree.append("\n");
}

return smallTree.toString();
}

public static String getLargeTriangle() {
return null;

StringBuilder largeTree = new StringBuilder();

for (int i = 1; i < 10; i++) {
for (int j = 0; j < i; j++) {
largeTree.append("*");
}
largeTree.append("\n");
}

return largeTree.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,10 @@ public void testGetRange2() {
Assert.assertEquals(expected, actual);
}














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

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