Given a sentence the task is to find the total number of vowels present in the sentence.
Example: Consider the sample text “Lorem Ipsum is simply dummy text of the printing and typesetting industry”. The program should find the total number of vowels in this sentence i.e., 18 vowels.
Java
import java.util.*;
public class VowelCount
{
public static void main(String Args[])
{
int l=0,count=0;
String str="";
char ch=' ';
Scanner sc=new Scanner(System.in);
System.out.print("Enter a Sentence: ");
str=sc.nextLine();
l=str.length();
for(int i=0;i<l;i++)
{
ch=str.charAt(i);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'||ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
{
count++;
}
}
System.out.println("Number of vowels: "+count);
}
}
Java