forked from phani653/Pattern-programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflag-pattern.java
93 lines (90 loc) · 3.71 KB
/
flag-pattern.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
public class IndianFlagExample {
public static void main(String[] args) {
int height = 26;
int width = 40;
int temp = 3;
for(int m = 1; m<= height; m++) {
for(int n = 1; n <= width; n++){
if(m <= 4) {
if(m == 1 || m == 4) {
if(n >= 15 && n<= 35) {
System.out.print("-");
} else {
System.out.print(" ");
}
} else {
if(m ==2 || m ==3) {
if(n == 15 || n == 35) {
System.out.print("|");
} else {
System.out.print(" ");
}
}
}
}
if(m > 4 && m <= 8) {
if(m <= 7) {
if(n == 15 || n == 35) {
System.out.print("|");
} else {
if(n >= 22 && n<= 28) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
} else {
if(n >= 15 && n<= 35) {
System.out.print("-");
} else {
System.out.print(" ");
}
}
}
if(m > 8 && m <= 11) {
if(m <= 10) {
if(n == 15 || n == 35) {
System.out.print("|");
} else {
System.out.print(" ");
}
} else {
if(n >= 15 && n <= 35) {
System.out.print("-");
} else {
System.out.print(" ");
}
}
}
if( m >= 12 && m <= 19) {
if(n == 15) {
System.out.print("|");
} else {
System.out.print(" ");
}
}
if( m >= 20) {
if(m % 2 == 0) {
if(n >= 15 - temp && n <= 15 + temp) {
System.out.print("-");
} else {
System.out.print(" ");
}
} else {
if(n == 15 - temp || n == 15 + temp) {
System.out.print("|");
} else {
System.out.print(" ");
}
}
}
}
if(m >= 20) {
if(m % 2 != 0) {
temp++;
}
}
System.out.print("\n");
}
}
}