Skip to content

Commit 71eb2cb

Browse files
committed
Exercise 7-B
1 parent 9779d80 commit 71eb2cb

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

ch07/MyLoopsC.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
public class MyLoopsC
2+
{
3+
public static void main(String[] args)
4+
{
5+
exercise7cForLoop();
6+
7+
exercise7cWhile();
8+
9+
exercise7cDoWhile();
10+
}
11+
12+
private static void exercise7cForLoop()
13+
{
14+
for (int x = 100; x >= -100; x -= 8)
15+
{
16+
System.out.println(x);
17+
}
18+
}
19+
20+
private static void exercise7cWhile()
21+
{
22+
int x = 100;
23+
while (x >= -100)
24+
{
25+
System.out.println(x);
26+
x -= 8;
27+
}
28+
}
29+
30+
private static void exercise7cDoWhile()
31+
{
32+
int x = 100;
33+
do{
34+
System.out.println(x);
35+
x -= 8;
36+
} while (x >= -100);
37+
}
38+
}

0 commit comments

Comments
 (0)