Friday, 24 October 2014

Program to enter a token/word in a mixed case and display the new token after deleting all the consonants

/* Program to enter a token/word in a mixed case and display the new token
  after deleting all the consonants*/
 
import java.util.Scanner;
public class vowels
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
       
        String st, ns="";
        int i,len;
        char ch;
       
        System.out.println("Enter a token/word");
        st=sc.next();
        len=st.length();
       
        // Extracting only consonants leaving vowels from the entered token
        for(i=0;i<len;i++)
        {
            ch=st.charAt(i);
            if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
                ns=ns+ch;
        }
       
        System.out.println();
        System.out.println();
       
        // Printing the new token with consonants only
        System.out.println("The new token after deleting all the consonants : "+ns);
         
    }
}
        

No comments:

Post a Comment