This one I almost have figured out (I believe). it is a program that takes a String in the main class and calls on a method to count the vowels inside the String. I then have to count each vowel (a,e,i,o,u) and input the total number of vowels (separately) into an array and return that array such that the output would be {1, 2, 1, 3, 1} or whatever it may be...any help?

public class VowelCount
    public static void main(String[] args)
            String VC = "black banana republic boots";
        public static int[] vowelCount (String list)
            int x = list.length();
            int[] aeiou = new int[4];
            if(list.substring(0, x).equals("a"))
            else if(list.substring(0, x).equals("e"))

            else if(list.substring (0, x).equals("i"))

            else if(list.substring (0, x).equals("o"))
            else if(list.substring(0, x).equals("u"))
            return aeiou;

Edited 7 Years Ago by MMD88: n/a

Use a for loop in you "vowelCount". Also, you can't print an array like that, use a for loop for that too. Look over the usage of "substring" again.

will they be nested for loops? I'm thinking not, but I don't know much about this stuff. and I will have to use a compound if statement, right? tryin to figure it out

Admin-You can delete this post. I figured it out
thanks for the help

This article has been dead for over six months. Start a new discussion instead.