-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteS.java
More file actions
105 lines (74 loc) · 1.85 KB
/
DeleteS.java
File metadata and controls
105 lines (74 loc) · 1.85 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Remove Element from the String
import java.util.*;
public class DeleteS
{
public static void main(String args[])
{
String s;
int p1;
int temp=0;
Scanner sc =new Scanner(System.in);
System.out.println("Enter the String : ");
s=sc.nextLine();
char a[]=s.toCharArray();
int n=a.length;
System.out.println("This Listed prpgram For Deleting ");
System.out.println("1.Enter to character");
System.out.println("2.Enter Position");
System.out.println("");
System.out.println("Choose Option if U want To Search ");
System.out.println("3.Option Not Availble Yet");
System.out.println("4.Option Not Availble Yet ");
System.out.println("How Many Time U want To Run: ");
int r=sc.nextInt();
int i;
while(r>0)
{
System.out.println("Choose Option what U want to Enter");
int d=sc.nextInt();
switch(d)
{
case 1:
{
System.out.println("Enter Character : ");
char c=sc.next().charAt(0);
String s1="";
for(i=0;i<n;i++)
{
if(a[i]!=c)
{
s1=s1+a[i];
}
}
System.out.println("After Deleting String: "+s1);
break;
}
case 2:
{
System.out.println("Enter the position U want to Delete");
int p=sc.nextInt();
for(i=p-1;i<n-1;i++)
{
a[i]=a[i+1];
}
n=n-1;
System.out.println("After Deleting the String ");
for(i=0;i<n;i++)
{
System.out.print(" "+a[i]);
}
break;
}
case 3:
{
}
default:
{
//System.out.println("Press Enter U If want to Exit");
System.exit(0);
}
}
r--;
}
}
}