13. Write a Java method that checks whether all the characters in a given string are vowels (a, e,i,o,u) or not. Return true if each character in the string is a vowel, otherwise return false
class VowelCharacters
{
static boolean checkVowelCharacters(String str)
{
str=str.toLowerCase();
for( char ch :str.toCharArray())
{
if( ch!='a' && ch!='e' && ch!='i' && ch!='o' && ch!='u')
{
return false;
}
}
return true;
}
public static void main(String st[])
{
String str1="aeiou";
String str2="hello";
System.out.println(" Is "+ str1 + " Vowel: \n" + checkVowelCharacters(str1));
System.out.println(" Is "+ str2 + " Vowel: \n" +checkVowelCharacters(str2));
}
}
OUTPUT
Is aeiou Vowel:
true
Is hello Vowel:
false