Java Program to Check Whether a Given Alphabets are Uppercase or Lowercase or Digits

This is a Java Program to Check if given Alphabets are Uppercase or Lowercase or Digits.

Enter any character as input. After that we match the ASCII value of that character against the given three cases. If that value matches then we get the output accordingly.

Here is the source code of the Java Program to Check if given Alphabets are Uppercase or Lowercase or Digits. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. public class Alphabet_Check 
  5. {
  6.     public static void main(String args[]) throws IOException
  7.     {
  8.         char m;
  9.         BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  10.         System.out.print("Enter any alphabet:");
  11.         m = (char) bf.read();
  12.         if(m >= 97 && m <= 123)
  13.         {
  14.             System.out.println("Lower Case");
  15.         }
  16.         else if(m >= 65 && m <= 96)
  17.         {
  18.             System.out.println("Upper Case");
  19.         }
  20.         else if(m >= 48 && m <= 57)
  21.         {
  22.             System.out.println("Digit");
  23.         }
  24.     }
  25. }

Output:

$ javac Alphabet_Check.java
$ java Alphabet_Check
 
Enter any alphabet:B
Upper Case
 
Enter any alphabet:z
Lower Case
 
Enter any alphabet:9
Digit

Sanfoundry Global Education & Learning Series – 1000 Java Programs.

advertisement
advertisement

Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.