Quote:
I have tried searching for a solution online
The first thing to do is to try to understand what is going on, otherwise, searching internet for a solution is expecting to miraculously find an exact solution on internet.
- Forge some sample inputs:
printOutVowels("aeiou");
printOutVowels("uoiea");
printOutVowels("aeiouaeiouaeiou");
printOutVowels("aeiouoiea");
...
You should conclude that the function outputs every vowel in order it is encountered in input. Which is a better definition for what is going on inside.
From this, you have to ask yourself : "How did I told the function that I to output only 1 time each vowel encountered ?"
Then you discover that you didn't told the function only 1 time each vowel encountered.
Advice use positive logic: "My function is doing this, that way.", It should be pretty close to the code.
and now describe the problem : "My function is doing this, that way, but I expect that behavior."
This should lead you an understanding of the problem, and this is a step to solution.