vowels = wordcount.vowelNum(); //counts the vowels
consonants = wordcount.consNum(); //counts the consonants, this is not working properly.
the consNum() method:
int length = word.length();
for(int i = 0; i < length; i++){
if(word.charAt(i) == 'a' || word.charAt(i) == 'u'|| word.charAt(i) == 'i'|| word.charAt(i) == 'e'|| word.charAt(i) == 'o'){
vowelCount++;
}
}
consCount = (word.length() - vowelCount);
return consCount;
the above method is giving me weird results, for example if i typed in "dexter" and it would say it has 2 consonants. the vowel count method, however, works.