Skip to content
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
68 changes: 61 additions & 7 deletions NumberUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,83 @@
public class NumberUtilities {

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

String result = "";
for (int i = 0; i < stop ; i++) {
result += i;
}
return result;

}

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


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

}


return result;
}

public static String getEvenNumbers(int start, int stop) {
return null;
String result = "";
int rem = start % 2;


if (rem != 0) {
for (int i = start+1; i < stop; i+=2) {
result += i;

}
return result;
} else {

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

}


return result;
}
}


public static String getOddNumbers(int start, int stop) {
return null;
String result = "";
int rem = start % 2;


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

}
return result;

}


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

String result = "";

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

int a = (int)Math.pow(i,exponent);
result += a;
} return result;
}

}

13 changes: 9 additions & 4 deletions README-TableUtilities.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# TableUtilities
* Ensure each of the test cases in the class [TableUtilitiesTest](https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/test/java/io/zipcoder/microlabs/mastering_loops/TableUtilitiesTest.java) successfully passes upon completion of each of the method stubs in the class [TableUtilities](https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/main/java/io/zipcoder/microlabs/mastering_loops/TableUtilities.java).
* Ensure each of the test cases in the class
* [TableUtilitiesTest]
* (https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/test/java/io/zipcoder/microlabs/mastering_loops/TableUtilitiesTest.java)
* successfully passes upon completion of each of the
* method stubs in the class [TableUtilities]
* (https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/main/java/io/zipcoder/microlabs/mastering_loops/TableUtilities.java).
* `String getLargeMultiplicationTable()`
* `String getSmallMultiplicationTable()`
* `String getMultiplicationTable(int width)`
Expand Down Expand Up @@ -39,7 +44,7 @@
## `String getSmallMultiplicationTable()`
* **Description**
* Generate a `String` representation of a multiplication table whose dimensions are `4` by `4`
### Example 1
* Sample Script

Expand Down Expand Up @@ -107,7 +112,7 @@
* **Description**
* Generate a `String` representation of a multiplication table whose dimensions are `9` by `9`

### Example
* Sample Script

Expand Down Expand Up @@ -176,7 +181,7 @@
* **Description**
* Given one integer, `width`, generate a `String` representation of a multiplication table whose dimensions are `width` by `width`

### Example 1
* Sample Script

Expand Down
2 changes: 1 addition & 1 deletion README-TriangleUtilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
* **Description**
* Given one integer, `n`, generate a `String` representation of a triangle whose base height and width is equal to `n`.

### Example
* Sample Script

Expand Down
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Leon's Loopy Lab
* Read each of the following `README` files and complete each of the asks.
* [README-NumberUtilities.md](./README-NumberUtilities.md)
* [README-TriangleUtilities.md](./README-TriangleUtilities.md)
* [README-TableUtilities.md](./README-TableUtilities.md)
# Leon's Loopy Lab
* Read each of the following `README` files and complete each of the asks.
* [README-NumberUtilities.md](./README-NumberUtilities.md)
* [README-TriangleUtilities.md](./README-TriangleUtilities.md)
* [README-TableUtilities.md](./README-TableUtilities.md)





















73 changes: 68 additions & 5 deletions TableUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,77 @@

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

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

for(int j=1; j<=5; j++){
int d = i * j;
String f = String.valueOf(d);
String o = " ";
if ( f.length() == 2) {
o = " ";

} else if ( f.length() == 3) {
o = "";
}
System.out.print(badBoy += o + i*j + " |");
}
badBoy += "\n";

}

return badBoy;
}



public static String getLargeMultiplicationTable() {
return null;
String badBoy = "";

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

for(int j=1; j<=10; j++){
int d = i * j;
String f = String.valueOf(d);
String o = " ";
if ( f.length() == 2) {
o = " ";

} else if ( f.length() == 3) {
o = "";
}
System.out.print(badBoy += o + i*j + " |");
}
badBoy += "\n";

}

return badBoy;
}

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

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

for(int j=1; j<= tableSize; j++){
int d = i * j;
String f = String.valueOf(d);
String o = " ";
if ( f.length() == 2) {
o = " ";

} else if ( f.length() == 3) {
o = "";
}
System.out.print(badBoy += o + i*j + " |");
}
badBoy += "\n";

}

return badBoy;
}

}
}

38 changes: 34 additions & 4 deletions TriangleUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,49 @@
public class TriangleUtilities {

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

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

public static String getTriangle(int numberOfRows) {
return null;
String result = "";
for(int i = 0; i < numberOfRows; i++){
for(int j = 0; j <= i; j++){
result += "*";
}
result += "\n";
}
return result;


}


public static String getSmallTriangle() {
return null;
String result = "";
for(int i = 0; i <= 3; i++){
for(int j = 0; j <= i; j++){
result += "*";
}
result += "\n";
}
return result;

}

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

}
}
Loading