I'm trying to use a for loop to examine each character in an array and print the character, it's position in the array, and what type of character it is (vowel, consonant, etc.). I have this so far:
char[] myName = new char[] {'J', 'o', 'h', 'n', ' ', 'D', 'o', 'e'};
System.out.print("\nMy name is: ");
for(int index=0; index < myName.length ; index++)
System.out.print(myName[index]);
for(char c : myName) {
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
{
System.out.println("The character located at position is a vowel.");
}
else if (c == 'j' || c == 'h' || c == 'n' || c == 'd')
{
System.out.println("The character located at position is a consonant.");
}
else if (c == ' ')
{
System.out.println("The character located at position is a space.");
}
How do I print the location of the character (i.e. "The character x located at position x is a vowel.")