public String emphasize(String phrase, char ch) { StringBuilder newPhrase = new StringBuilder(phrase); for (int i = 0; i < newPhrase.length(); i++) { char currentChar = newPhrase.charAt(i); if (Character.toLowerCase(currentChar) == Character.toLowerCase(ch)) { newPhrase.setCharAt(i, (i % 2 == 0) ? '*' : '+'); // if (i % 2 == 0) { // newPhrase.setCharAt(i, '*'); // } // else { // newPhrase.setCharAt(i, '+'); // } } } return newPhrase.toString(); }
public boolean isVowel(char ch) { String vowels = "aeiou"; ch = Character.toLowerCase(ch); int idx = vowels.indexOf(ch); boolean bVowel = false; if (idx != -1) { bVowel = true; } // System.out.println(String.valueOf(bVowel)); return bVowel; }