WAP TO INPUT A SENTENCE AND PRINT THE NUMBER OF WORDS WHICH ARE HAVING ATLEAST ONE VOWEL. (IN JAVA ICSE PROGRAM) STRING PROGRAM

 


import java.util.*;

class vowel

{

    public static void main(String args[])

    {

        Scanner in=new Scanner(System.in);

        String s,ws=" ";

        char ch;

        int counter=0,d=0;

        System.out.println("Enter a sentence");

        s=in.nextLine();

        s=s.toUpperCase();

        s=s+" ";

        int l=s.length();

        for(int i=0;i<l;i++)

        {

            ch=s.charAt(i);

            if(ch=='A'|| ch=='E' ||ch=='I'||  ch=='O' || ch=='U')

               counter++;

           ws=ws+ch;

          if(ch==' ')

      {

           if(counter>0)

         {

             d++;

           

         counter=0;

         ws="";


}

}

}

System.out.println("The number of words containing at least one vowel in it is="+d);

}

}

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

It looks like you're using an ad blocker. We rely on ads to keep our site free, please whitelist us!

Click here to continue

Please whitelist our site to continue enjoying our content.

Whitelist | Close