Advertisement
Marin126

Ejercicio2Recu

Dec 19th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /*
  4. * To change this license header, choose License Headers in Project Properties.
  5. * To change this template file, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8. /**
  9. *
  10. * @author anton
  11. */
  12. public class Ejercicio02 {
  13.  
  14. public static void main(String[] args) {
  15. Scanner sc = new Scanner(System.in);
  16.  
  17. System.out.print("Introduce un nΓΊmero: ");
  18. int num = Integer.parseInt(sc.nextLine());
  19. String[] cadenas = new String[num];
  20.  
  21. for (int i = 0; i < num; i++) {
  22. System.out.println("Introduzca la cadena " + i + ": ");
  23. cadenas[i] = sc.nextLine();
  24. }
  25. }
  26.  
  27. public static int cuentaVocales(String[] cadenas) {
  28. int resultado = 0;
  29. for (int i = 0; i < cadenas.length; i++) {
  30.  
  31. if (cadenas[i].contains("a")
  32. || cadenas[i].contains("e")
  33. || cadenas[i].contains("i")
  34. || cadenas[i].contains("o")
  35. || cadenas[i].contains("u")) {
  36. resultado ++;
  37.  
  38. }
  39. }
  40.  
  41. return resultado;
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement