forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoops7B.java
More file actions
39 lines (35 loc) · 746 Bytes
/
Loops7B.java
File metadata and controls
39 lines (35 loc) · 746 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
36
37
38
39
public class Loops7B
{
public static void main(String[] args)
{
System.out.println("For loop:");
forLoopUp();
System.out.println("While loop:");
whileLoopUp();
System.out.println("Do while loop:");
doWhileLoopUp();
}
private static void forLoopUp()
{
for(int i = 0;i < 101; i += 10)
System.out.println(i);
}
private static void whileLoopUp()
{
int i = 0;
while(i < 101)
{
System.out.println(i);
i +=10;
}
}
private static void doWhileLoopUp()
{
int i = 0;
do
{
System.out.println(i);
i += 10;
}while(i < 101);
}
}