Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. /**
  2. * @author Shane Kloosterman
  3. * @version 1.0
  4. * @since jan 2020
  5. * MIT License
  6. * Copyright 2020 Shane Kloosterman
  7. */
  8. public class VowelTest {
  9.  
  10. public static void main(String[] args) {
  11.  
  12. new VowelTest();
  13.  
  14. }
  15.  
  16.  
  17. public VowelTest() {
  18.  
  19. String tekst1 = "Aap";
  20. System.out.println(countVowel(tekst1));
  21. String tekst2 = "Deur";
  22. System.out.println(countVowel(tekst2));
  23. String tekst3 = "Dijk";
  24. System.out.println(countVowel(tekst3));
  25. String tekst4 = "Jelly";
  26. System.out.println(countVowel(tekst4));
  27. String tekst5 = "Ian";
  28. System.out.println(countVowel(tekst5));
  29.  
  30. }
  31.  
  32. // public int countVowel() {
  33. //
  34. // int count = 0;
  35. //
  36. // for (int i = 0; i < str.length(); i++) {
  37. // for (int x = i; x < str.length(); i++) {
  38. // for (int y = i; y < str.length(); i++) {
  39. // }
  40. // }
  41. //
  42. // }
  43.  
  44.  
  45. public int countVowel(String str) {
  46.  
  47. int count = 0;
  48.  
  49. for (int i = 0; i < str.length(); i++) {
  50. if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o' || str.charAt(i) == 'u' || str.charAt(i) == 'y') {
  51. count++;
  52. }
  53. }
  54. return count;
  55. }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement