13/12/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");
        }
    }
}
Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: