How do I check if a char is a vowel?

前端 未结 8 1117
醉酒成梦
醉酒成梦 2020-11-30 13:54

This Java code is giving me trouble:

    String word = 
    int y = 3;
    char z;
    do {
        z = word.charAt(y);
         if (z!=         


        
8条回答
  •  日久生厌
    2020-11-30 14:15

    For starters, you are checking if the letter is "not a" OR "not e" OR "not i" etc.

    Lets say that the letter is i. Then the letter is not a, so that returns "True". Then the entire statement is True because i != a. I think what you are looking for is to AND the statements together, not OR them.

    Once you do this, you need to look at how to increment y and check this again. If the first time you get a vowel, you want to see if the next character is a vowel too, or not. This only checks the character at location y=3.

提交回复
热议问题