English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm suppose to count the number of syllables. I'm doing flesch Index project.

public int syllableCount()
{
int syllable = 0;
for (int i = 0; i <= aWord.length(); i++)
{
do
{
aWord= aWord.substring(i,1);
}
while(aWord.contains("a"));
syllable = syllable +1;
}
return syllable;
}

2007-01-07 16:25:40 · 3 answers · asked by Zena 2 in Computers & Internet Programming & Design

aWord is my instance field.
I am trying to count the syllables even the ones counted together.
If I can't count one syllable what makes you think I can count all of them.

2007-01-07 17:07:26 · update #1

3 answers

There are many considerations that your program will not work. I may not be accurate enough to tell you that your program will work. Please try the following...
1. In method length(), try to remove () parenthesis.
2. Your do...while loop statement is steady and cannot iterate. I think it is better that you will use an If statement for it.
3. It is not all the times "a" is a perfect match to find the number of syllables, try other letters like "e", "i", "o", "u", and "y".
4. If all fails, please try to check your main class, if that method has some connections to it.

2007-01-07 17:17:35 · answer #1 · answered by red scar 2 · 0 0

I dont know exactly what is "aWord" here..i Think u must have declared it as global..but i think there is some problem with ur do-while loop..just check tht..could u pls also tell us what error is being shown n what editor r u using for java programmin? or r u not getting the desired output?

2007-01-07 16:35:06 · answer #2 · answered by cool one 2 · 0 0

Syllables can't be counted just by counting the letter "a".

What if you count all vowels, including "y" ?
sY - llA - blE = 3 syllables.

Oh, and vowels together cOUnt as one.

2007-01-07 16:32:32 · answer #3 · answered by Alan 6 · 0 0

fedest.com, questions and answers