forked from navinreddy20/Data-Structures-using-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNestedLoops.java
More file actions
84 lines (73 loc) · 2.35 KB
/
Copy pathNestedLoops.java
File metadata and controls
84 lines (73 loc) · 2.35 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
package org.apache.maven;
public class NestedLoops {
public static void main(String[] args) {
int i, j;
for (i = 1; i <= 5; i++) {
for (j = 1; j <= 4; j++) {
System.out.print("* ");
}
System.out.println("*");
}
int a = 1;
while (a <= 5) {
int b = 1;
while (b <= 4) {
System.out.print("# ");
b++;
}
System.out.println("#");
a++;
}
char k, l;
for (k = 65; k <= 67; k++) {
for (l = 67; l >= k+1; l--) {
System.out.print(l + " ");
}
System.out.println(k);
}
int row = 5;
int column = 5;
for (int x = 0; x < row; x++) {
for (int y = 0; y < column; y++) {
if (y == 0 || y == column - 1) {
System.out.print("@ ");
} else if (x==1&&y==column-4||x==2&&y==column-3||x==3&&y==column-2) {
System.out.print("@ ");
} else {
System.out.print(" ");
}
}
System.out.println();
}
// #Assignment
//1 prgm: 1-6 Numbers Pattern Logic
int m, n;
for (m = 1; m <= 6; m++) {
for (n = 1; n <= m - 1; n++) {
System.out.print(n + " ");
}
System.out.println(m);
}
//2 prgm: Alphabets Pattern Logic
char u, v;
for (u = 'A'; u <= 'C'; u++) {
for (v = 'A'; v <= u - 1; v++) {
System.out.print(v + " ");
}
System.out.println(u);
}
//3 prgm: Box Star Pattern Logic
int rows = 4;
int columns = 4;
for (int r = 0; r < rows; r++) {
for (int s = 0; s < columns; s++) {
if (r == 0 || r == rows - 1 || s == 0 || s == columns - 1) {
System.out.print("$ ");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}