Computer Science, asked by jedi1, 1 year ago

write a program in java to accept a string to count and display the number of vowels

Answers

Answered by roshisuhani12
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);
    }
}


jedi1: thx
Similar questions