forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo.java
More file actions
37 lines (30 loc) · 733 Bytes
/
Demo.java
File metadata and controls
37 lines (30 loc) · 733 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
public class Demo
{
public static void main(String[] args)
{
int i = 1;
int sum = 10;
while (i <= 10)
{
System.out.println(i + " " + sum);
i++;
sum = sum + 10;
}
System.out.println("Out of the while loop!");
i = 1;
sum = 10;
System.out.println("Starting the do while loop!");
do
{
System.out.println(i);
i++;
} while (i <= 10);
System.out.println("Out of the do while loop!");
for (int j = 1; j <= 10; j++)
{
sum += i;
System.out.println(sum);
}
System.out.println("Out of the for loop!");
}
}