So far I've written this code for this purpose...
"Complete the following program to find the first vowel in a word."
import java.util.Scanner;
public class FirstVowel
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
String word = in.next();
boolean found = false;
int i = 0;
String ch = word.substring(i, i + 1);
int position = 0;
for (i = 0; i < word.length(); i++) {
while (!found && position < word.length())
{
if ("aeiou".contains(ch.toLowerCase()))
{
found = true;
}
else
{
position++;
}
}
}
if (found)
{
System.out.println("First vowel: " + ch);
System.out.println("Position: " + position);
}
else
{
System.out.println("No vowels");
}
}
}```
However, my output is weird.
```Output differs. See highlights below.
Input
Mississippi
Your output
No vowels
Expected output
First vowel: i
Position: 1
2: Compare output
Input
able
Your output
First vowel: a
Position: 0
3: Compare output
Input
grrr!
Your output
No vowels
I think the issue is that it's not looking through all the characters in the string beyond the first, but I'm not sure how I could go about fixing that indexing issue in a while loop. Does anyone know how?
