Write a method called averageVowels that takes an ArrayList of String s as a parameter and returns the average number of vowel characters (a, e, i, o, u) in all String s in the list. If your method is passed an empty ArrayList , it should return 0.0 .
public static double averageVowels(ArrayList strList)
{
if(strList.isEmpty())
return 0.0;
double average = 0.0;
double count = 0;
for(int i = 0; i < strList.size(); i++)
{
String str = strList.get(i);
for(int j = 0; j < str.length(); j++)
{
char ch = Character.toLowerCase(str.charAt(j));
if(ch == 'a' || ch == 'e' || ch == 'i'
|| ch == 'o' || ch == 'u')
{
count++;
}
}
}
average = (double)count / strList.size();
return average;
}