Professional Documents
Culture Documents
Ques 1 - WAP to accept a string from the use and remove all words that
start with a vowel and print the resultant string.
Ans 1 - import java.util.Scanner;
class StringWithoutVowel{
public static void main(String args[]) throws Except
ion {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a String : ");
String str = sc.nextLine();
String words[] = str.split(" ");
for(int i = 0; i < words.length; i++) {
char ch = words[i].charAt(0);
if(ch == 'b'|| ch == 'c'|| ch == 'd' ||ch ==
'f' ||ch == 'g'||ch == ' '||ch == 'h'||ch ==
'j'||ch == 'k'||ch == 'l'||ch == 'm'||ch ==
'n'||ch == 'p'||ch == 'q'||ch == 'r'||ch ==
's'||ch == 't'||ch == 'v'||ch == 'w'||ch ==
'x'||ch == 'y'||ch == 'z') {
System.out.println(words[i]);
}
}
}
}
Output:-