
write a program thatt stores vowels (a,e,i,o and u)in an array. Ask the user to enter any character. The program should ignore the case of that character (uppercase or lowercase) and determine whether the entered character is vowel or not.

import java.util.Scanner;
public class Example1 {
public static void main(String[] args) {
char arr[] = { 'a', 'e', 'i', 'o', 'u' };
String brr;
boolean flag = false;
Scanner sc = new Scanner(System.in);
char ch;
System.out.println("Enter any character:");
brr = sc.nextLine();
if (brr.length() > 1)
System.out.println("It is not character. Please enter character");
else {
ch = brr.charAt(0);
System.out.println("It is character. " + ch);
for (int i = 0; i < arr.length; i++) {
if (arr[i] == ch) {
flag = true;
break;
}
}
if (flag)
System.out.println(ch + " is vowel.");
else
System.out.println(ch + " is consonant.");
}
}
}
Is this code is fruitful for you.
+++++++++ knapster +++++++++

import java.util.Scanner;
public class Example1 {
public static void main(String[] args) {
char arr[] = { 'a', 'e', 'i', 'o', 'u' };
String brr;
boolean flag = false;
Scanner sc = new Scanner(System.in);
char ch;
System.out.println("Enter any character:");
brr = sc.nextLine();
if (brr.length() > 1)
System.out.println("It is not character. Please enter character");
else {
ch = brr.toLowerCase().charAt(0);
for (int i = 0; i < arr.length; i++) {
if (arr[i] == ch) {
flag = true;
break;
}
}
if (flag)
System.out.println(brr + " is vowel.");
else
System.out.println(brr + " is consonant.");
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.