Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Shane Kloosterman
- * @version 1.0
- * @since jan 2020
- * MIT License
- * Copyright 2020 Shane Kloosterman
- */
- public class VowelTest {
- public static void main(String[] args) {
- new VowelTest();
- }
- public VowelTest() {
- String tekst1 = "Aap";
- System.out.println(countVowel(tekst1));
- String tekst2 = "Deur";
- System.out.println(countVowel(tekst2));
- String tekst3 = "Dijk";
- System.out.println(countVowel(tekst3));
- String tekst4 = "Jelly";
- System.out.println(countVowel(tekst4));
- String tekst5 = "Ian";
- System.out.println(countVowel(tekst5));
- }
- // public int countVowel() {
- //
- // int count = 0;
- //
- // for (int i = 0; i < str.length(); i++) {
- // for (int x = i; x < str.length(); i++) {
- // for (int y = i; y < str.length(); i++) {
- // }
- // }
- //
- // }
- public int countVowel(String str) {
- int count = 0;
- for (int i = 0; i < str.length(); i++) {
- 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') {
- count++;
- }
- }
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement