> I have the following code but i want to add a function which will allow
> me to count the number of vowels in the text file. I was wondering if
> anyone would be willing to give me some help with this
<snip>
> while ((line = myFile.readLine()) != null ) {
> String[] words = line.split(" ");
> numWords = numWords + words.length;
> for (int i = 0; i < words.length;i++) {
> numChar = numChar + words[i].length();
So, why not count the vowels somewhere right about here? You can iterate
through the chars here, checking for a, e, i, o, and u and increment a
counter, right?
> if(words[i].length() > longestWord) {
> longestWord = words[i].length();
> }
> lengths[words[i].length()] = lengths[words[i].length()] + 1;
> }
> }
By the way, you or someone like you just recently posted a similar
question just days ago...maybe you should google the question and
responses?
I'm surprised by these questions though. They show a significant lack of
fundamental, core principals: loops, iterations, equality, counters. I
don't mean to sound critical, although I do know that this does...but
maybe you need to spend some time with the TA to get some basic things
resolved.
--
John O'Conner
Lew - 02 Jan 2007 06:39 GMT
> By the way, you or someone like you
with, coincidentally, the same name,
> just recently posted a similar question just days ago...
> maybe you should google the question and responses?
- Lew