Counting Vowels in java
class vowels{
public static int findlowerCaseVowelCount(String str){
int len = str.length();
int vowelCount = 0;
for(int i=0; i<len; i++){
char ch = str.charAt(i);
if(Character.isLowerCase(ch) == true){
if(ch == 'a' || ch == 'e' || ch == 'i' || ch=='o' || ch == 'u'){
vowelCount++;
}
}
}
return vowelCount;
}
public static void main(String[] args) {
String s1 = "hello";
int count=findlowerCaseVowelCount(s1);
System.out.println(count);
}
}
Comments
Post a Comment