Hey people...
My problem is:
- -
Heaviest Word
Find the the heaviest word in an array.
One word is heavier than the other if it has more vocals than the other.
Vocal characters are ('a', 'e', 'i', 'o', 'u', 'y')
If two words have the same number of vocals, then heavier is the one which comes first alphabeticaly.
Input parameters:
words - array of words
Constraints:
words will have 1 to 10 elements inclusive
Return value:
The heaviest word.
Class Name:
HeaviestWord
Method :
public int heaviest(String[] words)
Test case 1:
heaviest({"a", "b", "c", "e"}) = "a"
Test case 2:
heaviest({"a", "b", "c", "ea"}) = "ea"
Test case 3:
heaviest({"zaaa", "yaab", "c", "e"}) = "yaab"
Test case 4:
heaviest({"akjqwhe", "asdasd", "qwe", "asde", "asdasd", "qweqwe", "qqqqqqq", "alksjd", "aeoi"}) = "aeoi"
Test case 5:
heaviest({"dddd", "cccc", "xxxx", "bbbb"}) = "bbbb"
Test case 6:
heaviest({"bc", "b"}) = "b"
- -
Here is my code:
public class HeaviestWord {
public String heaviest(String[] words) {
int br=0;
int no=0;
String hv = "";
for(String zbor : words){
for(int i=0; i<zbor.length(); i++){
if(zbor.charAt(i)== 'a'){ br++; }
if(zbor.charAt(i)== 'e'){ br++; }
if(zbor.charAt(i)== 'i'){ br++; }
if(zbor.charAt(i)== 'o'){ br++; }
if(zbor.charAt(i)== 'u'){ br++; }
if(zbor.charAt(i)== 'y'){ br++; }
}
hv = zbor;
}
return hv;
}
}
Now, I don't know how to restore the assembly word.
returned word should be just like this image:
[img]http://img218.imageshack.us/img218/5011/heav.jpg[/img]
Thanks...