//this program counts the vowels in a string
import java.util.*;
class CountVowels
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
System.out.print("Enter String: ");
String st = input.nextLine();
int count = 0;
for (int i = 0; i < st.length(); i++)
{
char c = st.charAt(i);
if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
{
count++;
}
}
System.out.println("There are" + " " + count + " " + "vowels in this string.");
}
}
No comments:
Post a Comment