Write a program to count the vowels in a string.
Answers
Answered by
6
import java. util. *;
class vowel
{
public static void main(String args[])throws Exception
{
Scanner sc=new Scanner(Sys tem . in);
String s;
int i ,ctr;
char ch;
System . out . println("Enter any word");
s=in . next();
s=s . toUpperCase();
for(i=0 ;i<s . length() ;i++)
{
ch= s. charAt(i);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
ctr ++ ;
}
System . out. println("Number of vowels are" + ctr);
}
}
s= hello
Similar questions
English,
6 months ago
History,
6 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Biology,
1 year ago