-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathLoopPractice.java
39 lines (34 loc) · 1.01 KB
/
LoopPractice.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public class LoopPractice {
//Function for While Loop
public static void practiceWhileLoop() {
// variable
int x = 0;
while(x < 5) {
System.out.println("The value of x is " + x);
x++;
}
System.out.println("This is the end of the While Loop.");
}
//Function for Do While Loop
public static void practiceDoWhileLoop() {
int x = 0;
do {
System.out.println("The value of x is " + x);
x++;
} while (x < 10);
System.out.println("This is the end of the Do While Loop.");
}
public static void practiceForLoop() {
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
System.out.println("("+x+","+y+")");
}
}
System.out.println("This is the end of the For Loop.");
}
public static void main(String[] args) {
practiceWhileLoop();
practiceDoWhileLoop();
practiceForLoop();
}
}