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.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Alphabet_Check
{
public static void main(String args[]) throws IOException
{
char m;
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter any alphabet:");
m = (char) bf.read();
if(m >= 97 && m <= 123)
{
System.out.println("Lower Case");
}
else if(m >= 65 && m <= 96)
{
System.out.println("Upper Case");
}
else if(m >= 48 && m <= 57)
{
System.out.println("Digit");
}
}
}
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.
Related Posts:
- Practice Information Technology MCQs
- Practice Programming MCQs
- Apply for Java Internship
- Apply for Computer Science Internship
- Check Java Books