Syllables

//Counts vowels in word and iterates through, adding a syllable for every vowel public class SyllableCounter{ public static void SyllMain(){ String[] words = {"cat", "hello", "world", "tennis", "episcopal", "count", "learn", "denise", "state","statement","fruit","calculation","spite","spiteful","reservation","late","lately","extreme","expensive"}; for (int i = 0;i<words.length;i++){ Sylls(words[i]); } } public static void Sylls(String wor){ String[] letts = wor.split("(?!^)"); int val = 0; String[] vows = {"a", "e", "i", "o", "u", "y","A","E","I","O","U","Y"}; for (int i = 0;i<letts.length;i++){ for(int e = 0; e<vows.length; e++){ if (letts[i].equals(vows[e])) val ++; } } System.out.println(wor + " " + val + ","); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.