M
matt
Here is my code:
public class VowelCount{
public static void main(String[] args) {
String[] firstNames =
{"Matthew","Anne","Gerard","Gerard","Jennifer"};
char[] vowels = {'a','e','i','o','u','A','E','I','O','U'};
int count = 0;
for(int x = 0; x < vowels.length; ++x){
for(int y = 0; y < firstNames.length; ++y){
if(vowels[x].indexOf(firstNames[y]) > 0){
count += 1;
}
}
}
System.out.println(count);
}
}
-----------------------
Here is the compile error:
C:\JAVAWO~1\Chapter.05>javac VowelCount.java
VowelCount.java:9: char cannot be dereferenced
if(vowels[x].indexOf(firstNames[y]) > 0){
^
1 error
public class VowelCount{
public static void main(String[] args) {
String[] firstNames =
{"Matthew","Anne","Gerard","Gerard","Jennifer"};
char[] vowels = {'a','e','i','o','u','A','E','I','O','U'};
int count = 0;
for(int x = 0; x < vowels.length; ++x){
for(int y = 0; y < firstNames.length; ++y){
if(vowels[x].indexOf(firstNames[y]) > 0){
count += 1;
}
}
}
System.out.println(count);
}
}
-----------------------
Here is the compile error:
C:\JAVAWO~1\Chapter.05>javac VowelCount.java
VowelCount.java:9: char cannot be dereferenced
if(vowels[x].indexOf(firstNames[y]) > 0){
^
1 error