Q-WAP TO COUNT THE NUMBER OF VOWELS PRESENT IN A STRING?

import java.io.*;
class vowel2
{
static void vowel(String str)
{
String v="aeiouAEIOU";
int c=0;
for(int i=0;i<str.length();i++)
{
char ch=str.charAt(i);
if(v.indexOf(ch)!=-1)
c=c+1;
}
System.out.println("TOTAL NUMBER OF VOWELS ARE "+c);
}

public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(newInputStreamReader(System.in));
String str="";
System.out.println("enter str");
str=br.readLine();
vowel(str);
}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s