Skip to content

'donnnnneee best day everr' #62

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 @@ -3,26 +3,72 @@

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

String evenvalue = "";

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

if (i %2 == 0){

evenvalue += "" + i;
}
}
return evenvalue;

}


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

String oddvalue = "";

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

if (i%2 != 0 ) {

oddvalue += "" + i;

}
}
return oddvalue;

}


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

String storesqnumbers = "";
//int i is equal and while i is less then stop, i increases by steps increments(may have worded wrong)
for (int i = start; i < stop; i += step) {
//I am now concatenating into my storesqnumbers and I had to cast, on Math.pow because I was getting a float
storesqnumbers += + (int)Math.pow(i,2);
}
//returning storesqnumbers
return storesqnumbers;
}


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

String holder = "";

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

holder += i;
}

return holder;
}


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

String exp_num = "";

for (int i = start; i < stop; i += step){
exp_num += "" +(int)Math.pow(i, exponent);
}
return exp_num;
}

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


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

//so I don't have to concatenate every string, I named it times
//my first for loop, created to look ht(height), the dimension is defined in the middle
//my 2nd for loop, created to look width(width), the dimension is defined in the middle
/*I actually got this portion from student help but I know what it means. The append
goes along with the string builder and times is just the title. String format will create a
formatted string without having to printf it. The %3 represents the field width of, "d" is decimal
integer, space, pipe, by the value of 1.
*/
//and then we are returning times to a string format and it passed.

//you have to append outside the inside loop because that loop PRINTS A ROW!

StringBuilder times = new StringBuilder();

for (int ht=1; ht<6; ht++){
for (int wd=1; wd<6; wd++){
times.append(String.format("%3d |", wd*ht));
}
times.append("\n");
}
return times.toString();
}





public static String getLargeMultiplicationTable() {
return null;
StringBuilder timest = new StringBuilder();

for (int h=1; h<11; h++){
for (int w=1; w<11; w++){
timest.append(String.format("%3d |", w*h));
}
timest.append("\n");
}
return timest.toString();
}



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

for (int n=1; n<21; n++){
for (int w=1; w<21; w++){
multit.append(String.format("%3d |", w*n));
}
multit.append("\n");
}
return multit.toString();
}
}







}

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,56 @@

public class TriangleUtilities {

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

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

//The aim of using StringBuilder, i.e reducing memory. Is it achieved?
//adding numberOfStars to StringBuilder allows for the length to be known up front
StringBuilder stars = new StringBuilder(numberOfStars);
//now we want to add * to the stars StringBuilder for the length of numberOfStars
stars.append("*");
//now we are returning our stars back to a string and it passes!!
return stars.toString();

}

public static String getSmallTriangle() {
return null;

StringBuilder shinyStar = new StringBuilder();

int h, w;
for (h = 1 ; h <= 4 ; h++) {
for (w = 1 ; w <= h ; w++) {
shinyStar.append("*");
}
shinyStar.append("\n");
}

return shinyStar.toString();
}




public static String getLargeTriangle() {
return null;

StringBuilder bigStar = new StringBuilder();

int ht, wd;
for (ht = 1 ; ht <= 10 ; ht++) {
for (wd = 1 ; wd <= ht ; wd++) {
bigStar.append("*");
}
bigStar.append("\n");
}

return bigStar.toString();






}
}
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