> I am trying to create a program which will allow the user to open there
> desired text file and count the number of Vowels, and lines in the
> text. As of yet i cant find or dont know how to produce this program. I
> need to use Java was wondering if anyone has any ideas.
Use the classes and methods in the java.io package to open the file.
Your friendly Java reference can tell you more. Read each line. Keep
count. Look at each character and see if it's a vowel. Keep count.
It should be beyond trivial for you to demonstrate 0.00001% effort and
1) use Google as a source of information, 2) read your friendly
textbook, and 3) try it yourself.

Signature
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Daniel Pitts - 31 Dec 2006 00:57 GMT
> > I am trying to create a program which will allow the user to open there
> > desired text file and count the number of Vowels, and lines in the
[quoted text clipped - 8 lines]
> 1) use Google as a source of information, 2) read your friendly
> textbook, and 3) try it yourself.
4) pay attention in class :-)
jupiter - 31 Dec 2006 04:07 GMT
>> > I am trying to create a program which will allow the user to
>> > open there
[quoted text clipped - 16 lines]
>> textbook, and 3) try it yourself.
> 4) pay attention in class :-)
That was my problem. But then again, I did get the chick with the
long legs so not all was lost.
>I am trying to create a program which will allow the user to open there
> desired text file and count the number of Vowels, and lines in the
> text. As of yet i cant find or dont know how to produce this program. I
> need to use Java was wondering if anyone has any ideas.
You didn't mention what language the text file is using and that could make
a difference. I'm not talking about the programming language which you are
using to parse the text file, I'm talking about the language used in the
text file.
Even if the language used in the text file is always English and you _know_
that it is always English, what do you do with the letter "y"? Is it a vowel
or a consonant? When I was in primary school, they taught that the vowels
were "a, e, i, o, u and _sometimes_ y". (I don't remember anyone ever
explaining when 'y' was considered a vowel and when it was considered a
consonant so I _suspect_ that the 'y' in "happy" is considered a vowel but
the 'y' in "yard" is considered a consonant without really being remotely
SURE.)
If the language in the text file isn't guaranteed to be English, the problem
gets much harder since you presumably don't know which language it is. And
while many languages are written using the same letters that we use in
English - sometimes with accents thrown in - those letters aren't always
pronounced the same as we pronounce them. So, in some cases, a letter that
might be a vowel to us could conceivably be a consonant in the other
language. (I can't actually think of an example of 'a', 'e', 'i', 'o' or 'u'
being considered a consonant in some other language but it seems possible
that such a case could exist.) And once you get into languages that don't
use the English alphabet - like Russian or Chinese - things get even
crazier. I'm pretty sure Russian has letters that are considered vowels -
although I'm not sure which ones they are - but I'm not at all sure if
Chinese or Arabic or Hindi even has the concept of vowels and consonants.
Now, I'm probably just overcomplicating the problem far beyond the
intentions of your instructor but, if you are hoping to do a thorough job
with this program, you may want to research this point and see if the
definition of a vowel is sufficiently firm that you can apply it to any
language you find in the text file that you are parsing. This could be worth
serious brownie points if you can actually handle a multitude of languages
and recognize the vowels in them regardless of the language chosen. :-)
--
Rhino
Karl Uppiano - 31 Dec 2006 22:37 GMT
>>I am trying to create a program which will allow the user to open there
>> desired text file and count the number of Vowels, and lines in the
[quoted text clipped - 41 lines]
> --
> Rhino
I thought Character.isVowel was localized! Ha ha ha!
Man, I crack myself up...
Oliver Wong - 02 Jan 2007 22:48 GMT
[context is counting vowels in a text file]
> Even if the language used in the text file is always English and you
> _know_ that it is always English, what do you do with the letter "y"? Is
[quoted text clipped - 19 lines]
> not at all sure if Chinese or Arabic or Hindi even has the concept of
> vowels and consonants.
According to Wikipedia, it should be not be said that a given letter or
character is or is not a vowel, but rather a given *sound* may or may not be
a vowel. So as you point out, the letter 'y' maps onto different sounds,
depending on the surrounding letters, and in some cases, the sound it maps
onto happens to be a vowel, and in other cases, the sound it maps onto
happens to not be a vowel. The definition Wikipedia gives is "a vowel is a
sound in spoken language that is characterized by an open configuration of
the vocal tract so that there is no build-up of air pressure above the
glottis.".
So for example, the word "beet" contains a single vowel, represented by
the sequence of characters "ee", as opposed to containing two vowels. And
"W" is a vowel in Welsh, as is "V" in Creek. And if you had an arbitrary
stream of characters, for which the pronounciation was not well defined,
would it even be meaningful to ask about the number of vowels within that
stream? Does "QREA" contain one vowel, or two, or three, something else? It
probably depends on whether I, as the inventor of this word, declare its
pronounciation to be "Kwri", or "Kree Ah" or "Ku Wree Ay" or something else.
If this is a school assignment (and the subject under study is *not*
linguistics), then I'd assume the teacher simply wants the student to count
the number of occurrences of the letters "a", "e", "i", "o", "u"; And
whether or not "y" should be included would be clarified by the teacher.
- Oliver
Check this URL out:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/BufferedReader.html
You should be able to figure it out from here I think.
Good luck,
Mearvk