-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLooplab1.java
More file actions
44 lines (37 loc) · 838 Bytes
/
Looplab1.java
File metadata and controls
44 lines (37 loc) · 838 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
40
41
42
43
44
/****************************************************
/Aziah Blanding
/Loop-Labs
/November 8, 2021
/Count by 5's using for, while, and do-while loops
*****************************************************/
public class Looplab1
{
public static void main(String[] args)
{
//executing for loop
System.out.print("For Loop: ");
int i;
for(i = 5; i <= 40; i = i + 5)
System.out.print(i + " ");
System.out.println();
//Executing while loop
System.out.print("While Loop: ");
int counter = 5;
while(counter <= 40)
{
System.out.print(counter + " ");
counter = counter + 5;
}
System.out.println();
//Executing do-while loop
System.out.print("Do-while Loop: ");
int count = 5;
do
{
System.out.print(count + " ");
count = count + 5;
}
while(count <= 40);
System.out.println();
}
}