How to count vowels and consonants and capitalizing first letter in a string while output using a method and return result

前端 未结 9 2425

If a user enters a string: hello there

it should output

Hello has 2 vowels
There has 3 consonants.

I know this is a f

9条回答
  •  眼角桃花
    2020-12-06 23:44

    import java.util.Scanner;
    
    //don't use space in between the input string;
    
     class StrRev {
    
        static String Vowels ="aeiouAEIOU";
    
        public static void main(String[] args){
             @SuppressWarnings("resource")
            Scanner name = new Scanner(System.in);
             String nm = name.nextLine();
    
             System.out.println();
             int vowel=0;
             int consonant=0;
            for(int i=0;i

提交回复
热议问题