There are five vowels in English letters in order that is an, e, I, o, u. Beneath I have composed a java program that will include the number of vowels in a string.
I have utilized change case to check for vowels, we can likewise do this using if proclamation.
On the off chance that you find any trouble to comprehend the rationale, at that point you can ask your inquiries.
Program
import java.util.Scanner;
class CountVowels
{
public static void main(String...s)
{
String str="";
int count=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter a string:");
str=sc.nextLine();
for(int i=0;i<str.length();++i)
{
switch(str.charAt(i))
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U': count++;
}
}
System.out.println("Number of vowels are "+count);
}
}
Output