|
@@ -2,7 +2,10 @@
|
2
|
2
|
|
3
|
3
|
|
4
|
4
|
public class NumberUtilities {
|
5
|
|
-
|
|
5
|
+ /**
|
|
6
|
+ * Takes in one parameter "stop" to create a string of numbers, starting
|
|
7
|
+ * from 0 to stop, not including stop.
|
|
8
|
+ */
|
6
|
9
|
|
7
|
10
|
public static String getRange(int stop) {
|
8
|
11
|
String numberRange = "";
|
|
@@ -14,6 +17,9 @@ public class NumberUtilities {
|
14
|
17
|
return numberRange;
|
15
|
18
|
}
|
16
|
19
|
|
|
20
|
+ /**
|
|
21
|
+ * Takes 2 parameters to dictate the range of the string.
|
|
22
|
+ */
|
17
|
23
|
public static String getRange(int start, int stop) {
|
18
|
24
|
String numberRange = "";
|
19
|
25
|
|
|
@@ -24,7 +30,9 @@ public class NumberUtilities {
|
24
|
30
|
return numberRange;
|
25
|
31
|
}
|
26
|
32
|
|
27
|
|
-
|
|
33
|
+ /**
|
|
34
|
+ * Uses the iterator to step and create the numbers in the range.
|
|
35
|
+ */
|
28
|
36
|
public static String getRange(int start, int stop, int step) {
|
29
|
37
|
String numberRange = "";
|
30
|
38
|
|
|
@@ -35,6 +43,10 @@ public class NumberUtilities {
|
35
|
43
|
return numberRange;
|
36
|
44
|
}
|
37
|
45
|
|
|
46
|
+ /**
|
|
47
|
+ * Uses the modulus operator to check for even/odd numbers to add to the
|
|
48
|
+ * numberRange string.
|
|
49
|
+ */
|
38
|
50
|
public static String getEvenNumbers(int start, int stop) {
|
39
|
51
|
String numberRange = "";
|
40
|
52
|
|
|
@@ -47,7 +59,9 @@ public class NumberUtilities {
|
47
|
59
|
return numberRange;
|
48
|
60
|
}
|
49
|
61
|
|
50
|
|
-
|
|
62
|
+ /**
|
|
63
|
+ * See "getEvenNumbers"
|
|
64
|
+ */
|
51
|
65
|
public static String getOddNumbers(int start, int stop) {
|
52
|
66
|
String numberRange = "";
|
53
|
67
|
|
|
@@ -60,7 +74,10 @@ public class NumberUtilities {
|
60
|
74
|
return numberRange;
|
61
|
75
|
}
|
62
|
76
|
|
63
|
|
-
|
|
77
|
+ /**
|
|
78
|
+ * Uses Math.pow to raise i to a specific power, then casts it to an int
|
|
79
|
+ * so it can be passed into the string to be returned.
|
|
80
|
+ */
|
64
|
81
|
public static String getExponentiations(int start, int stop, int exponent) {
|
65
|
82
|
String numberRange = "";
|
66
|
83
|
|