ICSE Java Program – Java Program to given Character is a Digit, Letter or a Special Character If-Else Statements

ICSE Java Program – Java Program to given Character is a Digit, Letter or a Special Character If-Else Statements

import java.io.*;

class Check1

{

public static void main(String args[])throws IOException

{

DataInputStream dis = new DataInputStream(System.in);

char ch ;

System.out.print(” Enter a character : “);

ch = (char) dis.read();

if(ch>=’a'&& ch<=’z’ || ch>=’A'&& ch<=’Z')

{

System.out.println(” Character is an Alphabet “);

if(ch==’a'||ch==’A'||ch==’e'||ch==’E'||ch==’i'||ch==’I'|| ch==’o'||ch==’O'||ch==’u'||ch==’U')

System.out.println(“Alphabet:” + ch + ” is a Vowel “);

else

System.out.println(” Alphabet:”+ch+”is a Consonant “);

}

else

{

if(ch>=’0′ && ch<=’9′)

System.out.println(ch + ” Character is a Digit “);

else

System.out.println(ch+” is a Special Character “);

}

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code: