|
@@ -1,11 +1,11 @@
|
1
|
1
|
# NumberUtilities
|
2
|
2
|
* Ensure each of the test cases in the class [NumberUtilitiesTest](https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/test/java/io/zipcoder/microlabs/mastering_loops/NumberUtilitiesTest.java) successfully passes upon completion of each of the method stubs in the class [NumberUtilities](https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/main/java/io/zipcoder/microlabs/mastering_loops/NumberUtilities.java).
|
3
|
|
- * `String getEvenNumbers(int start, int stop)`
|
|
3
|
+ * `String getEvenNumbers(int start, int stop)`
|
4
|
4
|
* `String getOddNumbers(int start, int stop)`
|
5
|
|
- * `String getSquareNumbers(int start, int stop, int step)`
|
6
|
|
- * `String getRange(int start, int stop, int step)`
|
7
|
|
- * `String getExponentiations(int start, int stop, int step, int exponent)`
|
8
|
|
-
|
|
5
|
+ * `String getSquareNumbers(int start, int stop, int step)`
|
|
6
|
+ * `String getRange(int start, int stop, int step)`
|
|
7
|
+ * `String getExponentiations(int start, int stop, int step, int exponent)`
|
|
8
|
+
|
9
|
9
|
|
10
|
10
|
|
11
|
11
|
|
|
@@ -22,10 +22,10 @@
|
22
|
22
|
```
|
23
|
23
|
// : Given
|
24
|
24
|
int stop = 11;
|
25
|
|
-
|
|
25
|
+
|
26
|
26
|
// : When
|
27
|
27
|
String outcome = NumberUtilities.getRange(stop);
|
28
|
|
-
|
|
28
|
+
|
29
|
29
|
// : Then
|
30
|
30
|
System.out.println(outcome);
|
31
|
31
|
```
|
|
@@ -57,10 +57,10 @@
|
57
|
57
|
// : Given
|
58
|
58
|
int start = 5;
|
59
|
59
|
int stop = 11;
|
60
|
|
-
|
|
60
|
+
|
61
|
61
|
// : When
|
62
|
62
|
String outcome = NumberUtilities.getRange(start, stop);
|
63
|
|
-
|
|
63
|
+
|
64
|
64
|
// : Then
|
65
|
65
|
System.out.println(outcome);
|
66
|
66
|
```
|
|
@@ -89,10 +89,10 @@
|
89
|
89
|
int start = 5;
|
90
|
90
|
int stop = 20;
|
91
|
91
|
int step = 5;
|
92
|
|
-
|
|
92
|
+
|
93
|
93
|
// : When
|
94
|
|
- String outcome = NumberUtilities.getRange(min, max, step);
|
95
|
|
-
|
|
94
|
+ String outcome = NumberUtilities.getRange(start, stop, step);
|
|
95
|
+
|
96
|
96
|
// : Then
|
97
|
97
|
System.out.println(outcome);
|
98
|
98
|
```
|
|
@@ -104,9 +104,9 @@
|
104
|
104
|
```
|
105
|
105
|
51015
|
106
|
106
|
```
|
107
|
|
-
|
108
|
|
-
|
109
|
|
-
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
110
|
110
|
|
111
|
111
|
|
112
|
112
|
|
|
@@ -128,22 +128,20 @@
|
128
|
128
|
// : Given
|
129
|
129
|
int start = 5;
|
130
|
130
|
int stop = 20;
|
131
|
|
-
|
|
131
|
+
|
132
|
132
|
// : When
|
133
|
|
- String outcome = NumberUtilities.getOddNumbers(min, max);
|
134
|
|
-
|
|
133
|
+ String outcome = NumberUtilities.getEvenNumbers(start, stop);
|
|
134
|
+
|
135
|
135
|
// : Then
|
136
|
136
|
System.out.println(outcome);
|
137
|
137
|
```
|
138
|
138
|
|
139
|
|
-
|
140
|
|
-
|
141
|
139
|
* Sample Output
|
142
|
140
|
|
143
|
141
|
```
|
144
|
142
|
681012141618
|
145
|
143
|
```
|
146
|
|
-
|
|
144
|
+
|
147
|
145
|
|
148
|
146
|
<br><br><br><br>
|
149
|
147
|
## `String getOddNumbers(int start, int stop)`
|
|
@@ -156,10 +154,10 @@
|
156
|
154
|
// : Given
|
157
|
155
|
int start = 5;
|
158
|
156
|
int stop = 20;
|
159
|
|
-
|
|
157
|
+
|
160
|
158
|
// : When
|
161
|
|
- String outcome = NumberUtilities.getOddNumbers(min, max);
|
162
|
|
-
|
|
159
|
+ String outcome = NumberUtilities.getOddNumbers(start, stop);
|
|
160
|
+
|
163
|
161
|
// : Then
|
164
|
162
|
System.out.println(outcome);
|
165
|
163
|
```
|
|
@@ -175,71 +173,22 @@
|
175
|
173
|
|
176
|
174
|
|
177
|
175
|
|
178
|
|
-
|
179
|
|
-
|
180
|
|
-
|
181
|
|
-
|
182
|
|
-
|
183
|
|
-
|
184
|
|
-
|
185
|
|
-
|
186
|
|
-
|
187
|
|
-
|
188
|
|
-
|
189
|
176
|
<br><br><br><br>
|
190
|
|
-## `String getSquareNumbers(int start, int stop)`
|
|
177
|
+## `String getExponentiations(int start, int stop, int exponent)`
|
191
|
178
|
* **Description**
|
192
|
|
- * Given two integers, `start`, and `stop`, return a `String` concatenation of all values squared between `start` up to and not including `stop`.
|
|
179
|
+ * Given three integers, `start`, `stop`, and `exponent`, return a `String` concatenation of all values, raised to the specified `exponent`, between `start` up to and including `stop`.
|
193
|
180
|
### Example
|
194
|
181
|
* Sample Script
|
195
|
182
|
|
196
|
183
|
```
|
197
|
184
|
// : Given
|
198
|
|
- int start = 5;
|
199
|
|
- int stop = 20;
|
200
|
|
-
|
201
|
|
- // : When
|
202
|
|
- String outcome = NumberUtilities.getOddNumbers(min, max);
|
203
|
|
-
|
204
|
|
- // : Then
|
205
|
|
- System.out.println(outcome);
|
206
|
|
- ```
|
207
|
|
-
|
208
|
|
-
|
209
|
|
-
|
210
|
|
-* Sample Output
|
211
|
|
-
|
212
|
|
- ```
|
213
|
|
- 25100225
|
214
|
|
- ```
|
215
|
|
-
|
216
|
|
-
|
217
|
|
-
|
218
|
|
-
|
219
|
|
-
|
220
|
|
-
|
221
|
|
-
|
|
185
|
+ int start = 1;
|
|
186
|
+ int stop = 4;
|
|
187
|
+ int exponent = 3;
|
222
|
188
|
|
223
|
|
-
|
224
|
|
-
|
225
|
|
-
|
226
|
|
-<br><br><br><br>
|
227
|
|
-## `String getExponentiations(int start, int stop, int step, int exponent)`
|
228
|
|
-* **Description**
|
229
|
|
- * Given four integers, `start`, `stop`, `step`, and `exponent`, return a `String` concatenation of all values, raised to the specified `exponent`, between `start` up to and not including `stop`, incrementing by the specified `step`.
|
230
|
|
-### Example
|
231
|
|
-* Sample Script
|
232
|
|
-
|
233
|
|
- ```
|
234
|
|
- // : Given
|
235
|
|
- int start = 5;
|
236
|
|
- int stop = 20;
|
237
|
|
- int step = 5;
|
238
|
|
- int exponent = 2;
|
239
|
|
-
|
240
|
189
|
// : When
|
241
|
|
- String outcome = NumberUtilities.getOddNumbers(min, max);
|
242
|
|
-
|
|
190
|
+ String outcome = NumberUtilities.getExponentiations(start, stop, exponent);
|
|
191
|
+
|
243
|
192
|
// : Then
|
244
|
193
|
System.out.println(outcome);
|
245
|
194
|
```
|
|
@@ -249,5 +198,5 @@
|
249
|
198
|
* Sample Output
|
250
|
199
|
|
251
|
200
|
```
|
252
|
|
- 25100225
|
|
201
|
+ 182764
|
253
|
202
|
```
|