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
48 changes: 37 additions & 11 deletions NumberUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,55 @@
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 result2 = "";
for (int i = start; i < stop; i++) {
result2 += i;
}
return result2;
}


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

public static String getEvenNumbers(int start, int stop) {
return null;
String result4 = "";
for (int i = start; i < stop; i++) {
if(i % 2 == 0) {
result4 += i;
}
}


return result4;
}

public static String getOddNumbers(int start, int stop) {
return null;
String result5 = "";
for (int i = start; i < stop; i++) {
if(i % 2 == 1) {
result5 +=i;
}
}


public static String getExponentiations(int start, int stop, int exponent) {
return null;
return result5;
}
public static String getExponentiations(int start, int stop, int exponent) {
String result6 = "";
for (int i = start; i <= stop; i++) {

result6 +=(int)Math.pow(i, exponent);
}
return result6;
}
}
34 changes: 30 additions & 4 deletions TableUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,40 @@

public class TableUtilities {
public static String getSmallMultiplicationTable() {
return null;
int x = 5;
String result1 = getMultiplicationTable(x);
return result1;
}

public static String getLargeMultiplicationTable() {
return null;
int y = 10;
String result2 = getMultiplicationTable(y);
return result2;
}

public static String getMultiplicationTable(int tableSize) {
return null;
String result = "";
for (int i=1; i <= tableSize; i++) {
for (int j=1; j <= tableSize; j++) {
int product = i * j;
if (product <10)
{
result += " " + product + " |";
}
else if ( product < 100 && product > 9)
{
result += " " + product + " |";
}
else
{
result += "" + product + " |";
}
}
result += "\n";
}

return result;
}
}

}

30 changes: 24 additions & 6 deletions TriangleUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,37 @@
public class TriangleUtilities {

public static String getRow(int numberOfStars) {
return null;
String result = "";
for(int i = 1; i <= numberOfStars; i++) {
result += "*";
}
return result;
}

public static String getTriangle(int numberOfRows) {
return null;
public static String getTriangle(int numberOfRows) {
String result2 = "";
for(int i = 1; i <= numberOfRows; i++)
{
result2 += getRow(i) + "\n" ;
}

return result2;
}

public static String getSmallTriangle() {
return null;
String result3 ="";
for(int i = 1; i <= 4; i++)
{
result3 += getRow(i) + "\n";
}
return result3;
}

public static String getLargeTriangle() {
return null;
String result4 ="";
for(int i = 1; i <= 9; i++)
{
result4 += getRow(i) + "\n";
}
return result4;
}
}
22 changes: 11 additions & 11 deletions package.bluej
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ dependency3.to=TableUtilities
dependency3.type=UsesDependency
editor.fx.0.height=722
editor.fx.0.width=800
editor.fx.0.x=537
editor.fx.0.y=28
objectbench.height=164
editor.fx.0.x=523
editor.fx.0.y=66
objectbench.height=179
objectbench.width=484
package.divider.horizontal=0.6
package.divider.vertical=0.7560627674750356
package.editor.height=523
package.editor.width=382
package.editor.x=20
package.editor.y=57
package.frame.height=759
package.divider.vertical=0.7223880597014926
package.editor.height=477
package.editor.width=390
package.editor.x=100
package.editor.y=24
package.frame.height=728
package.frame.width=508
package.numDependencies=3
package.numTargets=6
Expand Down Expand Up @@ -61,14 +61,14 @@ target4.showInterface=false
target4.type=ClassTarget
target4.width=120
target4.x=80
target4.y=70
target4.y=50
target5.height=50
target5.name=NumberUtilitiesTest
target5.showInterface=false
target5.type=UnitTestTargetJunit4
target5.width=120
target5.x=110
target5.y=40
target5.y=20
target6.association=TriangleUtilitiesTest
target6.height=50
target6.name=TriangleUtilities
Expand Down