forked from OpenGuide/Java-Guide-for-Beginners
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLoops.java
More file actions
35 lines (35 loc) · 933 Bytes
/
Loops.java
File metadata and controls
35 lines (35 loc) · 933 Bytes
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
public class Loops
{
public static void number(int x)
{
//using while loop
while (x < 10) {
++x;
System.out.println(x);
}
}
public static void even(int z)
{
do {
System.out.println (z);
z += 2;
} while (z <= 10);
}
public static void table(int y)
{
//using for loop
int i;
for (i = 1; i <= 10; ++i) {
System.out.println(i*y);
}
}
public static void main(String[] args)
{
System.out.println("Number from 1 to 10");
number(0);
System.out.println("Even Numbers between 0 to 10");
even(0);
System.out.println("Table of 8");
table(8);
}
}