/* CSE 142, Autumn 2007, Marty Stepp This program demonstrates boolean methods with String and char. */ import java.util.*; // for Scanner public class Vowels { public static void main(String[] args) { if (isVowel('q')) { System.out.println("q is now a vowel i guess."); } if (isVowel('e')) { System.out.println("e is a vowel."); } String s1 = "eieio"; if (isEntirelyVowels(s1)) { System.out.println("The first string is entirely vowels!"); } if (isEntirelyVowels("marty stepp")) { System.out.println("The second string is entirely vowels!"); } } // Returns whether the given character is a vowel (a, e, i, o, u). public static boolean isVowel(char letter) { return (letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o' || letter == 'u'); } // Returns whether the given String contains only vowels as characters. public static boolean isEntirelyVowels(String s) { for (int i = 0; i < s.length(); i++) { if (!isVowel(s.charAt(i))) { return false; } } return true; } }