954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Having difficulty with a WordCount Program

I've created a program that counts the amt. of characters, words, and lines in a text file...I also need it to count the number of blank lines and the number of vowels in the text document. I don't know why, but I cannot seem to get it to work. If anyone can give me some pointers, I'd very much appreciate it. Thanks much!

nevets56
Newbie Poster
1 post since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

when you read the file, you read it line by line I guess?
What's a special characteristic of a blank line? Hint: it has to do with the number of characters on it after stripping whitespace.

What's a vowel? How can you detect it? When you know that all you need to know is how to loop through your input and count them.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

You could have an array of vowels which you could campare with every :( letter and if theres a match increment a vowelCount variable :)

MrScruff
Junior Poster in Training
89 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

I'm not sure what method you are using to do this program, but a simple way to count the vowels would be to use the String Tokenizer class and set the delimeters to vowels. Use a while structure that checks .hasMoreTokens and loops through until there aren't any left. I recently made a program to do much of the same things, and have some code if you want to see an example. If I have made myself unclear, just drop me a line at [email]TMcClish@gmail.com[/email]
Later
-tom

mcclth
Newbie Poster
10 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You