|
|
@@ -99,7 +99,12 @@ public class WriteLoops {
|
|
99
|
99
|
// Write a nested FOR loop(s), where one counts from
|
|
100
|
100
|
// 0 to less than 20 and the inner one counts from 0 to 4
|
|
101
|
101
|
// calling
|
|
|
102
|
+ for (int i = 0; i < 20; i++){
|
|
|
103
|
+
|
|
|
104
|
+ for (int j = 0; j <=4; j++){
|
|
102
|
105
|
w = w + 1;
|
|
|
106
|
+ }
|
|
|
107
|
+ }
|
|
103
|
108
|
// each time through the inner loop
|
|
104
|
109
|
|
|
105
|
110
|
return w;
|
|
|
@@ -114,7 +119,15 @@ public class WriteLoops {
|
|
114
|
119
|
// prints “Hello Zipcode” instead of the statement w = w + 1;
|
|
115
|
120
|
|
|
116
|
121
|
// calling
|
|
117
|
|
- w = w + 1;
|
|
|
122
|
+ for (int i = 5; i<=105; i++) {
|
|
|
123
|
+ if (i > 51) {
|
|
|
124
|
+ System.out.println("Hello Zipcode");
|
|
|
125
|
+ }
|
|
|
126
|
+ else {
|
|
|
127
|
+ w = w + 1;
|
|
|
128
|
+ }
|
|
|
129
|
+ }
|
|
|
130
|
+
|
|
118
|
131
|
// each time through the inner loop
|
|
119
|
132
|
|
|
120
|
133
|
return w;
|
|
|
@@ -145,13 +158,18 @@ public class WriteLoops {
|
|
145
|
158
|
int w = 0;
|
|
146
|
159
|
|
|
147
|
160
|
// you need to use a .equals for two Strings.
|
|
148
|
|
-
|
|
|
161
|
+ while (!gpsCurrentLocation().equals("Home")){
|
|
|
162
|
+ driveSomeMore();
|
|
|
163
|
+
|
|
|
164
|
+
|
|
149
|
165
|
// calling
|
|
150
|
166
|
w = w + 1;
|
|
151
|
167
|
// each time through the inner loop
|
|
|
168
|
+ }
|
|
|
169
|
+ System.out.println("Honey, I'm Home!");
|
|
152
|
170
|
|
|
153
|
171
|
|
|
154
|
|
- return w;
|
|
|
172
|
+ return w;
|
|
155
|
173
|
}
|
|
156
|
174
|
|
|
157
|
175
|
// Getting harder...
|
|
|
@@ -167,11 +185,14 @@ public class WriteLoops {
|
|
167
|
185
|
int runningScore = 0;
|
|
168
|
186
|
|
|
169
|
187
|
// do your while loop here
|
|
170
|
|
-
|
|
171
|
|
- // calling
|
|
|
188
|
+ while ( runningScore < highestScore ){
|
|
|
189
|
+ runningScore = currentScore + runningScore;
|
|
172
|
190
|
w = w + 1;
|
|
|
191
|
+ currentScore = gameNextScore();
|
|
|
192
|
+
|
|
|
193
|
+ // calling
|
|
173
|
194
|
// each time through the inner loop
|
|
174
|
|
-
|
|
|
195
|
+ }
|
|
175
|
196
|
return w; // >= 3;
|
|
176
|
197
|
}
|
|
177
|
198
|
|
|
|
@@ -184,9 +205,13 @@ public class WriteLoops {
|
|
184
|
205
|
int runningScore = 0;
|
|
185
|
206
|
|
|
186
|
207
|
// do your while loop here
|
|
187
|
|
-
|
|
188
|
|
- // calling
|
|
|
208
|
+ do { runningScore = currentScore + runningScore;
|
|
189
|
209
|
w = w + 1;
|
|
|
210
|
+ currentScore = gameNextScore();
|
|
|
211
|
+
|
|
|
212
|
+ // calling
|
|
|
213
|
+
|
|
|
214
|
+ } while ( runningScore < highestScore );
|
|
190
|
215
|
// each time through the inner loop
|
|
191
|
216
|
|
|
192
|
217
|
return w >= 3;
|
|
|
@@ -200,9 +225,17 @@ public class WriteLoops {
|
|
200
|
225
|
int w = 0;
|
|
201
|
226
|
String adminPhoneNumber = "+1 202 456 1111";
|
|
202
|
227
|
|
|
|
228
|
+ while (serverIsRunning() == true) {
|
|
|
229
|
+ waitFor(5);
|
|
|
230
|
+ w = w + 1;
|
|
|
231
|
+ }
|
|
|
232
|
+ if (serverIsRunning() == false) {
|
|
|
233
|
+ sendEmergencyText("Help!", adminPhoneNumber);
|
|
|
234
|
+ tryServerRestart("Help!", adminPhoneNumber);
|
|
|
235
|
+ }
|
|
203
|
236
|
|
|
204
|
237
|
// calling
|
|
205
|
|
- w = w + 1;
|
|
|
238
|
+
|
|
206
|
239
|
// each time through the inner loop
|
|
207
|
240
|
|
|
208
|
241
|
return w;
|