This is a Java program that uses a switch statement to check whether a given character is a vowel or a consonant. Here's how the program works:
Note that in the switch statement, multiple cases are grouped together to check for vowels. This is possible because the action to be taken is the same in each case (i.e., printing out that the character is a vowel). This is called "grouping" in a switch statement.
Also note that in this program, only single character input is being considered. If the user enters more than one character, only the first character will be used and the rest will be ignored.
import java.util.Scanner; //Group Switch public class group_switch { public static void main(String args[]) { char c; System.out.println("Enter The Character : "); Scanner in =new Scanner(System.in); c=in.next().charAt(0); switch (c) { case 'a': case 'e': case 'i': case '0': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': System.out.println(c + " is a Vowels"); break; default: System.out.println(c + " is Consonant"); break; } } }
Enter The Character : u u is a VowelsTo download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions