-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveConsonant.java
More file actions
22 lines (19 loc) · 857 Bytes
/
RemoveConsonant.java
File metadata and controls
22 lines (19 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package prachi.stringpractice;
import java.util.Scanner;
public class RemoveConsonant {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
StringBuffer str = new StringBuffer(s);
String s1 = new String();
System.out.println(str);
for (int i = 0; i < str.length(); i++) {
if (!(s.charAt(i) == 'a' || s.charAt(i) == 'e' || s.charAt(i) == 'i' || s.charAt(i) == 'o' ||s.charAt(i) == 'u'
|| s.charAt(i) == 'A' || s.charAt(i) == 'E' || s.charAt(i) == 'I' || s.charAt(i) == 'O' || s.charAt(i) == 'U'
|| Character.isDigit(s.charAt(i)) || s.charAt(i) == ' ')) {
s1 = s1 + Character.toString(s.charAt(i));
}
}
System.out.println(s1);
}
}