-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecoding_String_with_Star.java
More file actions
47 lines (38 loc) · 1.07 KB
/
Decoding_String_with_Star.java
File metadata and controls
47 lines (38 loc) · 1.07 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
package technicals;
//Here we have to take an user given string , remove all the vowels then convert all the upper case letters to lower case and print a * before of every consonants.
// Like : Input -->AIMpajjiexe
// : Output --> *m*p*j*j*x
import java.util.*;
public class Star {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the code");
String s = sc.next();
char [] ch = s.toCharArray();
//removing vowels
for(int i =0;i<ch.length;i++)
{
if((ch[i]=='a'||ch[i]=='A')||(ch[i]=='e'||ch[i]=='E')||(ch[i]=='I'||ch[i]=='i')||(ch[i]=='O'||ch[i]=='o')||(ch[i]=='U'||ch[i]=='u'))
{
ch[i]='#';
}
}
//making an array free of #
ArrayList<Character> f = new ArrayList<>();
for(int i =0;i<ch.length;i++)
{
if(ch[i]!='#')
f.add(ch[i]);
}
System.out.print('*');
for(int i =0;i<f.size()-1;i++)
{
if(Character.isUpperCase(f.get(i)))
System.out.print(Character.toLowerCase(f.get(i))+"*");
else
System.out.print(f.get(i)+"*");
}
System.out.print(f.get(f.size()-1));
}
}