12/13/2016

Java Program to Check if Given Alphabets are Uppercase or Lowercase or Digits

Problem:- Java Program to Check if given Alphabets are Uppercase or Lowercase or Digits or Java Program to test if a character is uppercase/lowercase/number or Java Program To Check Character Is Uppercase / Lowercase / Digit / Special Symbol or Determine character is a capital, small case, digit or special symbol or Java code to check number of uppercase letters, lowercase letters.

Explanation:- As we know that Uppercase(A, B, C........Z) or Lowercase ( a,b,c.....z ) or a Digit ( 1,2,3,.......9 ), or a Special Symbol ( #,@,<,> ). Now 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 the character is between 65 to 90 then You Entered UPPERCASE if it is 97 to 122 then you entered LOWER CASE if it is between 48 to 57 then it is a DIGIT And for rest print SPECIAL SYMBOLS.


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




Java Program To Check Character Is Uppercase / Lowercase / Digit / Special Symbol


/* 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");
        }
    }
}

No comments:

Post a Comment