Tuesday, 13 December 2016

Java Program To Check Character Is Uppercase, Lowercase Alphabet Or A Digit Or A Special Symbol

Problem:- C Program To Check Character Is Uppercase( Like A,B,C........Z) , Lowercase ( Like a,b,c.....z )  Alphabet Or A Digit ( Like 1,2,3,.......9 ) , Or A Special Symbol ( Like #,@,<,> ) .

To Solve this problem we will use ASCII Value if you have any problem with ASCII Value You Can Check Java Program for Print ASCII Value Of Any Character.  if character is between 65 to 90 then You Entered UPPER CASE if it is 97 to 122 Then You Entered LOWER CASE if it is between 48 to 57 then it is a DIGIT And Rest Are SPECIAL SYMBOLS.

See Also :- C++ Program To Check Character Is Uppercase, Lowercase Alphabet Or A Digit Or A Special Symbol

Solution :-

/* Program By Ghanendra Yadav
   Visit http://www.programmingwithbasics.com/
*/
import java.io.*;
public class keycheck 
{
    public static void main(String args[]) throws IOException
    {
        char key;
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Press any Key:");
        key = (char) bf.read();

        if(key >= 97 && key <= 123)
        {
            System.out.println(" You Press Lower Case"); //for lower case letter
        }

        else if(key >= 65 && key <= 96) //for upper case letter
        {
            System.out.println(" You Press Upper Case");
        }
        else if(key >= 48 && key <= 57) //for digit
        {
            System.out.println(" You Press Digit");
        }
else 
        {
            System.out.println(" You Press Special Symbol");
        }
    }
}

See Also :-  C Program To Check Character Is Uppercase, Lowercase Alphabet Or A Digit Or A Special Symbol

Output:-


Java Program To Check Character Is Uppercase, Lowercase Alphabet Or A Digit Or A Special Symbol

No comments:
Write comments

Recommended Posts × +