Q:

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

0

ava 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 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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

 

Output:

Press any Key:6

 You Press Digit

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now