-
Notifications
You must be signed in to change notification settings - Fork 0
/
Looplab5.java
72 lines (67 loc) · 1.31 KB
/
Looplab5.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/****************************************************
/Aziah Blanding
/Loop-Labs
/November 8, 2021
/Output time tables using for, while, and do-while loops
*****************************************************/
public class Looplab5
{
public static void main(String[] args)
{
//Executing for loop
System.out.println("For Loop: ");
int mult = 0;
int i;
for(i = 1; i <= 5; i++)
{
for(mult = 1; mult <= 10; mult++)
System.out.println(i + "*" + mult +" = " + (i*mult));
System.out.print("\n");
}
//Executing while loop
System.out.println("While Loop: ");
int num = 1;
int numtotal = 1;
int counter = 1;
while(numtotal <= 10)
{
while(counter <= 10)
{
while(num <= 5)
{
System.out.print(num + "*" + counter + " = " + (counter*num) + " ");
num++;
}
num = 1;
System.out.print("\n");
counter++;
}
numtotal++;
}
//break
System.out.println("\n");
//Executing do-while loop
System.out.println("Do-while Loop: ");
int n = 1;
int count = 1;
int total = 1;
do
{
do
{
do
{
System.out.print(n+"*"+count+" = "+(n*count)+" ");
n++;
}
while(n <= 5);
n = 1;
System.out.println(" ");
count++;
}
while(count <= 10);
total++;
}
while(total <= 1);
}
}