Hello guys,
can someone help me with Simple Code?
Example:
a b c d e f g h i j k l m n o p q r s t u v w x y z
Vowel: A, E, I, O, U,
I need main and method.~
If I enter m, the next Vowel is o, so Output is: 2
How can I code this to have the output 2?
Question 2:
Input x and Output is 3 ( the distance from U is 3 and after z, there aren't any vowel)
Question 3:
Input a and Output is 0 (its stay 0 from Vowel because the letter is vowel itself)
Anyone any idea? please use simple code.
Thanks
What I have tried:
Question 2:
public static char closeVowel(char character) {
if(character == 'z' || character == 'Z')
return (char) (value - 25);
if(isVowel(character)) {
return character;
} else {
return closeVowel((char) (value - 1));
}
}
public static boolean isVowel(char character) {
return "aeiouAEIOU".indexOf(character) >= 0;
}
what to write inside main method? I dont wanna use indexof, is there a way to simple code it? for beginner to understand?
Question 3 ( no code yet)