-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYT36.java
More file actions
60 lines (51 loc) · 1.52 KB
/
YT36.java
File metadata and controls
60 lines (51 loc) · 1.52 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
/*
* H HELLO HELLO O
* HE HELL ELLO LO
* HEL HEL LLO LLO
* HELL HE LO ELLO
* HELLO H O HELLO
*/
import java.io.*;
class YT36
{
public static void main(String[] args)throws IOException
{
int ch;
String s="HELLO";
int L=s.length();
InputStreamReader I = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(I);
System.out.println("Enter the choice: 1/2/3/4");
ch=Integer.parseInt(br.readLine());
switch (ch)
{
case 1:
for(int i=1; i<=5; i++)
{
System.out.println(s.substring(0, i));
}
break;
case 2:
for(int i=L; i>=1; i--)
{
System.out.println(s.substring(0, i));
}
break;
case 3:
for(int i=0; i<L; i++)
{
System.out.println(s.substring(i, 5));
}
break;
case 4:
for(int i=L; i>=0; i--)
{
System.out.println(s.substring(i, 5));
}
break;
default:
System.out.println("Wrong Choice");
break;
}
}
}