Computer Science, asked by sayyedsajdeen786, 5 months ago

Write a program that input a word and print it such that all vowels are deleted​

Answers

Answered by Oreki
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