Java program to check whether entered character is uppercase or lowercase

Java program to check whether entered character is uppercase or lowercase. This is a Java program that determines whether the given Alphabets are Uppercase, Lowercase, or Digits. Any character can be used as input. After that, we compare the ASCII value of that character to the three cases provided. If that value is the same, the output will be the same. The source code for the Java program to determine whether given Alphabets are Uppercase, Lowercase, or Digits is available here.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main
{
public static void main(String args[]) throws IOException
{
char m;
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter any letter");
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("Number");
}
}
}

 

Output:

Enter any letter g
Lower Case

What is IOExpection in java program

IOException is a checked exception that must be handled correctly by the application developer. That means that if a file is not found when your program is looking for it, an FileNotFoundException will be issued. IOException has a subtype called FileNotFoundException. 

To define an exception in Java, use the throws keyword. It informs the programmer that an exception may occur, hence it is preferable for the programmer to write exception handling code in order to maintain regular flow.

What is buffered reader in java program

The Java class BufferedReader consumes text from the input stream. It buffers the characters so that it may read characters, arrays, and other data efficiently. It inherits the reader class, which makes the code more efficient because the readline() method allows us to read the data line by line.

What is InputStreamReader program in java

An InputStreamReader is a converter between byte and character streams: It reads bytes and converts them to characters with the help of a charset. The charset it uses can be provided explicitly or by name, or the platform’s default charset can be allowed.

What is if else if program in java

The conditional statements in Java are as follows: If a particular condition is true, use if to specify a block of code to be run. If the same condition is false, use otherwise to specify a block of code to run. If the initial condition is false, use else if to define a new condition to test.