class Main{
public static void main(String[] args){
String str = "Hello World";
int vowel = 0, cons = 0;
for(int i = 0; i < str.length(); i++){
char ch = str.charAt(i);
if(Character.isLetter(ch)){
switch(ch){
case 'a' :
case 'A' :
case 'e' :
case 'E' :
case 'i' :
case 'I' :
case 'o' :
case 'O' :
case 'u' :
case 'U' : vowel++; break;
default : cons++;
}
}
}
System.out.println("Number of Vowels : " + vowel);
System.out.println("Number of Consonents : " + cons);
}
}
Number of Vowels : 3
Number of Consonents : 7