Skip to content

Instantly share code, notes, and snippets.

@carlosdlf
Created January 18, 2016 22:23
Show Gist options
  • Save carlosdlf/c0ad52864537bdd50e23 to your computer and use it in GitHub Desktop.
Save carlosdlf/c0ad52864537bdd50e23 to your computer and use it in GitHub Desktop.
public class ContarVocales {
public static void main(String[] args) {
String vocales = "aeiou";
String palabra = "murcielago";
int cantidadVocales = 0;
for (int i = 0; i < palabra.length(); i++) {
char letter = palabra.charAt(i);
if(vocales.contains(letter+"")){
cantidadVocales++;
}
}
System.out.println(palabra + "tiene "+cantidadVocales + " vocales" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment