write a program in java to accept a string to count and display the number of vowels
Answers
Answered by
5
import java.io.*;
import java.util.*;
public class VowelsCount{
public static void main(String args[]){
String st;
int i,count=0;
Scanner s=new Scanner(System.in);
st=s.next();
for(i=0;i<st.length();i++){
if(st.charAt(i)=='a' || st.charAt[i]=='e' || st.charAt[i]=='i' || st.charAt[i]=='o' || st.charAt[i]=='u' || st.charAt[i]=='A' || st.charAt[i]=='E' || st.charAt[i]=='I' || st.charAt[i]=='O' || st.charAt[i]=='U')
count+=1;
}
System.out.println("Number of vowels is:"+count);
}
}
import java.util.*;
public class VowelsCount{
public static void main(String args[]){
String st;
int i,count=0;
Scanner s=new Scanner(System.in);
st=s.next();
for(i=0;i<st.length();i++){
if(st.charAt(i)=='a' || st.charAt[i]=='e' || st.charAt[i]=='i' || st.charAt[i]=='o' || st.charAt[i]=='u' || st.charAt[i]=='A' || st.charAt[i]=='E' || st.charAt[i]=='I' || st.charAt[i]=='O' || st.charAt[i]=='U')
count+=1;
}
System.out.println("Number of vowels is:"+count);
}
}
jedi1:
thx
Similar questions
English,
8 months ago
Social Sciences,
8 months ago
Math,
1 year ago
Math,
1 year ago
Biology,
1 year ago