-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYT01.java
More file actions
59 lines (53 loc) · 1.48 KB
/
YT01.java
File metadata and controls
59 lines (53 loc) · 1.48 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
import java.io.*;
class YT01
{
public static void main(String[] args)throws IOException
{
int ch;
InputStreamReader I = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(I);
System.out.println("Enter the choice: 1 for Triangle pattern & 2 for Rectangle pattern ");
ch= Integer.parseInt(br.readLine());
System.out.println("RESULT: ");
switch (ch)
{
case 1:
int n=1;
int r=4;
for(int i=0; i<r; i++)
{
for(int j=0; j<=i; j++)
{
System.out.print((5*n)+" ");
n++;
}
System.out.println();
}
break;
case 2:
int row=4;
for(int i=1; i<=row; i++)
{
if(i%2!=0)
{
for(int j=1; j<=6; j++)
{
System.out.print("#");
}
}
else
{
for(int j=1; j<=6; j++)
{
System.out.print("&");
}
}
System.out.println();
}
break;
default:
System.out.println("Wrong choice");
break;
}
}
}