Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Program to check Vowel or Consonant using Switch Case

import java.util.Scanner;
class JavaExample
{
   public static void main(String[ ] arg)
   {
	boolean isVowel=false;;
	Scanner scanner=new Scanner(System.in);
	System.out.println("Enter a character : ");
	char ch=scanner.next().charAt(0); 
	scanner.close();
	switch(ch)
	{
	   case 'a' :
	   case 'e' :
    	   case 'i' :
	   case 'o' :
	   case 'u' :
	   case 'A' :
	   case 'E' :
	   case 'I' :
	   case 'O' :
	   case 'U' : isVowel = true;
	}
	if(isVowel == true) {
	   System.out.println(ch+" is  a Vowel");
	}
	else {
	   if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
		System.out.println(ch+" is a Consonant");
	   else
		System.out.println("Input is not an alphabet");		
        }
   }
}
Comment

PREVIOUS NEXT
Code Example
Java :: replace range from array java 
Java :: return index using matcher java 
Java :: Java extract string between two strings 
Java :: newinstance in java giving exception 
Java :: how to add classpath in spring boot 
Java :: system out java quick 
Java :: java structure 
Java :: recursion java 
Java :: scrollbar in textarea java 
Java :: can you override static methods in java 
Java :: how to use a switch statement in java 
Java :: char to charsequence in java 
Java :: java method exercises 
Java :: java constructor 
Java :: arraylist add at index 
Java :: java sort array int 
Java :: string program to calculate number of characters in a string java 
Java :: remove java ubuntu 20.04 
Java :: java swing tablecellrenderer 
Java :: what are the chances that i pass this coming up test 
Java :: devoluciones redsys api 
Sql :: how to get the size of the database in postgresql 
Sql :: service postgres status 
Sql :: update sql server from another table 
Sql :: print oracle 
Sql :: display all databases 
Sql :: sql server read uncommitted 
Sql :: sql query to get column data type in sql 
Sql :: oracle list packages 
Sql :: convert_tz mysql 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =