Write a program that input a word and print it such that all vowels are deleted
Answers
Answered by
3
Code:
import java.util.Scanner;
public class RemoveVowels {
static boolean isVowel(char letter) {
return "aeiou".indexOf(Character.toLowerCase(letter)) != -1;
}
public static void main(String[ ] args) {
System.out.print("Enter a word - ");
String word = new Scanner(System.in).next( ),
newString = "";
for (int i = 0; i < word.length( ); i++) {
char letter = word.charAt(i);
if (!isVowel(letter))
newString += letter;
}
System.out.println("Word without vowels - " + newString);
}
}
Sample I/O:
Enter a word - Hello
Word without vowels - Hll
Similar questions