Hey so I dont want someone to just show me the code, but I've been struggling to get this to work for hours. I need to write a program that finds all the words with consecutive vowels in them... this is what I have so far...
-we are given a string array called words of all the words in the dictionary from a linked text file
-i changed the string array to char array so it would be easier to check each letter for being a vowel and then I set my vowels as a string and converted them to a char array....from here I made 3 int variable represent the index of the char, vowel, and word in their respective arrays...i believe my code is right up to here....
now how could i go through each word and check if it contain first an a, then an e, ,i,o,u and if it contains all 5 in that order (it doesnt matter if other vowels are inbetween for example sacrilegious works) then i would want to add it to the list of words that fits the category (named foundWords) any ideas?
import java.io.*;
import java.util.*;
public class FindStrangeWords {
public static void main (String[] argv)
{
myTests ();
mainTest ();
}
static void myTests ()
{
// INSERT YOUR TEST CODE HERE.
}
static void mainTest ()
{
String[] words = WordTool.getDictionary ();
findConsecVowelWords (words);
}
static void findConsecVowelWords (String[] words)
{
int foundWords = 0;
int vowelCount = 0;
String vowelCheck = "aeiou";
char[] vowel = vowelCheck.toCharArray();
for(int i=0;i<words.length;i++){
char[] letters = words[i].toCharArray();
for(int k=0;k<letters.length;k++){
for(int j=0;j<vowel.length;j++){
if (vowel[j] != letters[k]){
vowelCount=0;
}
else {
vowelCount++;
}
if(vowelCount>4){
foundWords++;
vowelCount=0;
System.out.println(words[i]);
System.out.println("Word Found!");
System.out.println(foundWords);
}
}
}
}
}
}