|
@@ -18,10 +18,10 @@ public class WriteLoops {
|
18
|
18
|
public int oneToFive() {
|
19
|
19
|
int w = 0;
|
20
|
20
|
|
21
|
|
- // Write a FOR loop that counts from 1 to 10.
|
|
21
|
+ for (w = 0; w < 5; w++); {// Write a FOR loop that counts from 1 to 10.
|
22
|
22
|
// calling
|
23
|
23
|
w = w + 1;
|
24
|
|
- // each time through the loop
|
|
24
|
+ }// each time through the loop
|
25
|
25
|
|
26
|
26
|
// this will tell the test how many times the loop executed.
|
27
|
27
|
return w;
|
|
@@ -30,10 +30,9 @@ public class WriteLoops {
|
30
|
30
|
public int oneToTen() {
|
31
|
31
|
int w = 0;
|
32
|
32
|
|
33
|
|
- // Write a FOR loop that counts from 1 to 10.
|
34
|
|
- // calling
|
|
33
|
+ for (w = 0; w < 10; w++); {// Write a FOR loop that counts from 1 to 10.
|
35
|
34
|
w = w + 1;
|
36
|
|
- // each time through the loop
|
|
35
|
+ }// each time through the loop
|
37
|
36
|
|
38
|
37
|
return w;
|
39
|
38
|
}
|
|
@@ -41,21 +40,21 @@ public class WriteLoops {
|
41
|
40
|
public int startAtTwentyOne() {
|
42
|
41
|
int w = 0;
|
43
|
42
|
|
44
|
|
- // Write a FOR loop that makes 10 iterations, start at 21.
|
|
43
|
+ for (w = 21; w < 31; w++) {// Write a FOR loop that makes 10 iterations, start at 21.
|
45
|
44
|
// calling
|
46
|
45
|
w = w + 1;
|
47
|
|
- // each time through the loop
|
48
|
|
-
|
|
46
|
+ }// each time through the loop
|
|
47
|
+ System.out.print(w);
|
49
|
48
|
return w;
|
50
|
49
|
}
|
51
|
50
|
|
52
|
51
|
public int countDown() {
|
53
|
52
|
int w = 0;
|
54
|
53
|
|
55
|
|
- // Write a FOR loop that counts down from 100 to 0.
|
|
54
|
+ for (w = 100; w >= 0; w--;) {// Write a FOR loop that counts down from 100 to 0.
|
56
|
55
|
// calling
|
57
|
56
|
w = w + 1;
|
58
|
|
- // each time through the loop
|
|
57
|
+ }// each time through the loop
|
59
|
58
|
|
60
|
59
|
return w;
|
61
|
60
|
}
|
|
@@ -63,10 +62,10 @@ public class WriteLoops {
|
63
|
62
|
public int byTwoTo32() {
|
64
|
63
|
int w = 0;
|
65
|
64
|
|
66
|
|
- // Write a FOR loop from 0 to 32 by 2s.
|
|
65
|
+ for (w = 0; w < 32; w += 2) {// Write a FOR loop from 0 to 32 by 2s.
|
67
|
66
|
// calling
|
68
|
67
|
w = w + 1;
|
69
|
|
- // each time through the loop
|
|
68
|
+ }// each time through the loop
|
70
|
69
|
return w;
|
71
|
70
|
}
|
72
|
71
|
|