import java.util.*; public class VowelCheck { public static void main(String[] args) { String s; char letter; Scanner input = new Scanner(System.in); System.out.print("Enter a letter: "); s = input.next(); if (s.length() > 1) { throw new IllegalStateException("Input must be single letter."); } if (isVowel(s.charAt(0))) { System.out.println("Letter is a vowel"); } else { System.out.println("Letter is not a vowel"); } } //---------------------------------------------- // Precondition: letter is an uppercase or // lowercase letter (in the range 'A' ... 'Z' or 'a' ... 'z') . // Postcondition: The value returned by the // method is true if letter is a vowel; // otherwise the value returned by the method is // false. public static boolean isVowel(char c) { String vowels = "aeiouAEIOU"; return (vowels.indexOf(c) >= 0); } }