Wednesday, 4 June 2014

Finding vowels in a string

import java.io.*;
class vowels
{
    public static void main()throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("ENTER A STRING");
        String s=br.readLine();
        int l=s.length();
        char array[]=new char[l];
        for(int i=0;i<l;i++)
        {
            array[i]=s.charAt(i);
        }
        int counter=0;
        for(int i=0;i<l;i++)
        {
            if(array[i]=='a' || array[i]=='e' || array[i]=='i' || array[i]=='o' || array[i]=='u')
            counter++;
        }
        System.out.println("total number of vowels in the sentence are"+counter);
    }
}



Shashank Chauhan
Naveen Dengani

No comments:

Post a Comment