Sunday 15 December 2013

Get the count of each vowel in a string

public class JavaApplication7 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        System.out.println("Please enter some text");
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String names=br.readLine().toLowerCase();
        StringTokenizer stk=new StringTokenizer(names);
        String vowels="";
        while(stk.hasMoreTokens()){
            String c=stk.nextToken();
            if(c.startsWith("a")||c.startsWith("e")||c.startsWith("i")||c.startsWith("o")||c.startsWith("u"))
                vowels=vowels+" "+c;
        }
        System.out.println(vowels);
       
    }
}

No comments:

Post a Comment