Computer
WAP to count the number of vowels in a String?

WAP to count the number of vowels in a String?
import java.util.Scanner;
class Vowels
{
public static void main (String args[])
{
Scanner sc = new Scanner (System.in);
System.out.println (“Enter the String”);
String str = sc.nextLine ();
char[]chars=str.toCharArray();
int count= 0;
for (char cha : chars)
{
switch (cha)
{
case ‘a’:
case ‘e’:
case ‘i’:
case ‘o’:
case ‘u’:
count ++;
break ;
}
}
System.out.println(“Number of vowels in string=” + count);
}
}

Very nice post. I certainly love this site. Continue the good work! Vally Benjamin Rather