|
@@ -135,13 +135,13 @@ public class WriteLoops {
|
135
|
135
|
public int driveHome() {
|
136
|
136
|
int w = 0;
|
137
|
137
|
|
138
|
|
- // you need to use a .equals for two Strings.
|
139
|
|
-
|
140
|
|
- // calling
|
|
138
|
+ while (!gpsCurrentLocation().equals("Home")) {
|
|
139
|
+ driveSomeMore();
|
141
|
140
|
w = w + 1;
|
142
|
|
- // each time through the inner loop
|
143
|
|
-
|
144
|
|
-
|
|
141
|
+ // you need to use a .equals for two Strings.
|
|
142
|
+ }
|
|
143
|
+ System.out.print("Honey, I'm Home!");
|
|
144
|
+
|
145
|
145
|
return w;
|
146
|
146
|
}
|
147
|
147
|
|
|
@@ -157,12 +157,13 @@ public class WriteLoops {
|
157
|
157
|
int currentScore = gameNextScore();
|
158
|
158
|
int runningScore = 0;
|
159
|
159
|
|
160
|
|
- // do your while loop here
|
161
|
|
-
|
162
|
|
- // calling
|
|
160
|
+ while (runningScore < highestScore) {// do your while loop here
|
|
161
|
+ runningScore += currentScore;
|
|
162
|
+ currentScore = gameNextScore();
|
163
|
163
|
w = w + 1;
|
164
|
|
- // each time through the inner loop
|
165
|
|
-
|
|
164
|
+ }
|
|
165
|
+ // calling
|
|
166
|
+
|
166
|
167
|
return w; // >= 3;
|
167
|
168
|
}
|
168
|
169
|
|
|
@@ -174,10 +175,13 @@ public class WriteLoops {
|
174
|
175
|
int currentScore = gameNextScore();
|
175
|
176
|
int runningScore = 0;
|
176
|
177
|
|
177
|
|
- // do your while loop here
|
178
|
|
-
|
179
|
|
- // calling
|
180
|
|
- w = w + 1;
|
|
178
|
+ do {
|
|
179
|
+ runningScore += currentScore;
|
|
180
|
+ currentScore = gameNextScore();
|
|
181
|
+ w = w + 1;// do your while loop here
|
|
182
|
+ }
|
|
183
|
+ while (runningScore < highestScore);// calling
|
|
184
|
+
|
181
|
185
|
// each time through the inner loop
|
182
|
186
|
|
183
|
187
|
return w >= 3;
|
|
@@ -191,28 +195,37 @@ public class WriteLoops {
|
191
|
195
|
int w = 0;
|
192
|
196
|
String adminPhoneNumber = "+1 202 456 1111";
|
193
|
197
|
|
194
|
|
-
|
|
198
|
+ while (serverIsRunning() == true) {
|
|
199
|
+ waitFor(5);
|
|
200
|
+
|
|
201
|
+ if (serverIsRunning() == false) {
|
|
202
|
+ sendEmergencyText("Help!", adminPhoneNumber);
|
|
203
|
+ tryServerRestart("",adminPhoneNumber);
|
|
204
|
+
|
|
205
|
+ w = w + 1;
|
195
|
206
|
// calling
|
196
|
|
- w = w + 1;
|
197
|
|
- // each time through the inner loop
|
198
|
207
|
|
199
|
|
- return w;
|
|
208
|
+ // each time through the inner loop
|
|
209
|
+ }
|
|
210
|
+ }
|
|
211
|
+ return w;
|
200
|
212
|
}
|
201
|
|
-
|
202
|
213
|
// Declare an “int” i. Set i to 7.
|
203
|
214
|
// Write a WHILE loop that checks “i” is less than 50,
|
204
|
215
|
// and if it is, add 7 to “i”
|
205
|
216
|
public int loop50by7() {
|
206
|
217
|
int w = 0;
|
|
218
|
+ int i = 7;
|
207
|
219
|
|
208
|
|
-
|
|
220
|
+ while (i < 50) {
|
|
221
|
+ i += 7;
|
209
|
222
|
// calling
|
210
|
223
|
w = w + 1;
|
211
|
224
|
// each time through the inner loop
|
212
|
225
|
|
213
|
|
- return w;
|
214
|
|
- }
|
215
|
|
-
|
|
226
|
+ }
|
|
227
|
+ return w;
|
|
228
|
+ }
|
216
|
229
|
int[] threes_array = { 3, 6, 9, 12, 15, 18, 21 };
|
217
|
230
|
|
218
|
231
|
// Foo is method that add the first 7 factors of three together and prints
|
|
@@ -241,15 +254,16 @@ public class WriteLoops {
|
241
|
254
|
public int rewriteFooAsFor() {
|
242
|
255
|
int w = 0;
|
243
|
256
|
int sumOfThrees = 0;
|
244
|
|
-
|
245
|
|
-
|
|
257
|
+ int numSum = sumOfThrees;
|
|
258
|
+ for (int i = 0; i < numSum; i++) {
|
|
259
|
+ sumOfThrees += sumOfThrees; //not sure how to indicate the index of it through normal words now..
|
246
|
260
|
// calling
|
247
|
261
|
w = w + 1;
|
248
|
262
|
// each time through the inner loop
|
249
|
263
|
|
250
|
264
|
System.out.print("The Sum is ");
|
251
|
265
|
System.out.println(sumOfThrees);
|
252
|
|
-
|
|
266
|
+ }
|
253
|
267
|
return w;
|
254
|
268
|
}
|
255
|
269
|
|
|
@@ -258,12 +272,12 @@ public class WriteLoops {
|
258
|
272
|
public int rewriteFooAsWhile() {
|
259
|
273
|
int w = 0;
|
260
|
274
|
int sumOfThrees = 0;
|
|
275
|
+ for (int i = 0; i < sumOfThrees; i++) {
|
261
|
276
|
|
262
|
|
-
|
263
|
277
|
// calling
|
264
|
278
|
w = w + 1;
|
265
|
279
|
// each time through the inner loop
|
266
|
|
-
|
|
280
|
+ }
|
267
|
281
|
System.out.print("The Sum is ");
|
268
|
282
|
System.out.println(sumOfThrees);
|
269
|
283
|
|
|
@@ -280,13 +294,15 @@ public class WriteLoops {
|
280
|
294
|
public int manageYardAndJunior() {
|
281
|
295
|
int w = 0;
|
282
|
296
|
boolean onTime = true;
|
283
|
|
-
|
284
|
|
- // ADD YOUR CODE here.
|
|
297
|
+ boolean yardNeedsMowed = true;
|
|
298
|
+ while (isSummer() == true) {
|
|
299
|
+ if (yardNeedsMowed == true) {
|
|
300
|
+ yellAtJuniorToMowLawn();
|
|
301
|
+ w = w + 1;
|
|
302
|
+ }
|
|
303
|
+ sendJuniorBackToSchool("First Day"); // ADD YOUR CODE here.
|
285
|
304
|
|
286
|
|
- // be sure to call
|
287
|
|
- w = w + 1;
|
288
|
|
- // each time inside the loop
|
289
|
|
-
|
|
305
|
+ }
|
290
|
306
|
return w;
|
291
|
307
|
}
|
292
|
308
|
|
|
@@ -298,29 +314,31 @@ public class WriteLoops {
|
298
|
314
|
public int tallyVote1() {
|
299
|
315
|
int w = 0;
|
300
|
316
|
int numberOfVotes = voteTallies.length;
|
|
317
|
+ for (int i = 0; i < numberOfVotes; i++) {
|
|
318
|
+ return numberOfVotes;
|
301
|
319
|
|
302
|
|
-
|
303
|
|
- // calling
|
304
|
|
- w = w + 1;
|
305
|
|
- // each time through the inner loop
|
306
|
|
-
|
|
320
|
+ }
|
|
321
|
+ w = w + 1;
|
307
|
322
|
return w;
|
308
|
323
|
}
|
309
|
324
|
|
310
|
325
|
// Given an array voteTallies[], write a WHILE loop that prints out each value
|
311
|
326
|
// in the array. You should declare and use an index “idx” to keep track of
|
312
|
327
|
// where you are.
|
313
|
|
- public int tallyVote2() {
|
|
328
|
+ /*public int tallyVote2() {
|
314
|
329
|
int w = 0;
|
315
|
330
|
int numberOfVotes = voteTallies.length;
|
316
|
|
-
|
|
331
|
+ int idx = 0;
|
|
332
|
+ while (int index < numberOfVotes) {
|
|
333
|
+ sumOfThrees = sumOfThrees + threes_array[index];
|
317
|
334
|
|
318
|
335
|
// calling
|
319
|
336
|
w = w + 1;
|
320
|
337
|
// each time through the inner loop
|
321
|
338
|
|
322
|
339
|
return w;
|
323
|
|
- }
|
|
340
|
+ Running out of time - will continue, but want to make sure something is submitted
|
|
341
|
+ } */
|
324
|
342
|
|
325
|
343
|
/**
|
326
|
344
|
* CONGRATS, you've written all the code. Does it all pass their tests?!?
|