#Array-Java(find vowelString)

6 messages · Page 1 of 1 (latest)

umbral flax
#

Would you willing to help me to solve the problem in Java(Pic1+Pic2 are the questions and some hints):i feel hard to get the each word in string to compare with the VowelStrings since each String is in a array. Thank you so much if anyone could teach me.

fierce relicBOT
#

This post has been reserved for your question.

Hey @umbral flax! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

mystic blade
# umbral flax Would you willing to help me to solve the problem in Java(Pic1+Pic2 are the ques...
public class Concrete2 {
    private static boolean bool=true;
    private static int countNum=0;
    private static final String[] STR_ARR={"are","amy","u"};
    private static final int LEFT=0;
    private static final int RIGHT=2;
    public static void main(String[] args) {
        Concrete2 concrete2=new Concrete2();
        int answer=concrete2.vowelStrings();
        System.out.println(answer);
    }

    int vowelStrings(){
        class CheckIfVowel{
            int count=0;
            private boolean passString(String string){
                count=0;
                checkString(string,'a');
                checkString(string,'e');
                checkString(string,'i');
                checkString(string,'o');
                checkString(string,'u');
                return count==2;
            }
            private void checkString(String string,char vowel){
                if (string.charAt(0)==vowel){
                     count++;
                }
                if (string.charAt(string.length()-1)==vowel){
                    count++;
                }
            }

        }
        CheckIfVowel checkIfVowel=new CheckIfVowel();
        for (int i=LEFT;i<=RIGHT;i++){
             bool=checkIfVowel.passString(STR_ARR[i]);
            if (bool) countNum++;
        }
        return countNum;
    }
}``` test this code through different cases it's not the best
#

tell me if it's not showing expected output

warm glen
# umbral flax Would you willing to help me to solve the problem in Java(Pic1+Pic2 are the ques...

I'll give you some pseudocode maybe that'll help.

public int vowelStrings(String[] words, int left, int right) {
    count = 0
    while left is smaller or equal to right:
        word = words[left]
        if the first character and the last character of the word are both vowels:
          increase count by 1
    return count
}

and here is the pseudocode of a method you could use to determine whether a character is a vowel or not

public boolean isVowel(char character){
  character = Convert character to lower case
  return true if character is a vowel, false otherwise
}