check if given alphabets are upper or lower
Table of Contents
In this article, we will discuss the concept of Program to check if given alphabet is upper or lower case in Java
In this post, we are going to learn how to write a program to check whether given English alphabet is Upper case or Lower case using if else in Java language
In this code, we are going to learn how to check the given English alphabet is Upper case or Lower case using if-else statements in Java language
Program 1
import java.util.Scanner;
public class Check_UpperLower1{
public static void main(String args[]){
char ch;//declare aa character variable
Scanner scan=new Scanner(System.in);
//create a scanner object for input
System.out.println("Enter a Alphabet only to check upper or lower :");
ch=scan.next().charAt(0);;// reading the input from the user
if(ch>='A' && ch<='Z'){
System.out.println(ch+" is an upper case letter ");
}//check upper case letter
else{
System.out.println(ch+" is a lower case letter ");
}//print lower case letter
}
} When the above code is executed, it produces the following result
Case 1
Enter a Alphabet only to check upper or lower : A A is an Upper case letter
Case 2
Enter a Alphabets only to check upper or lower : s s is a Lower case letter
In this code, we are going to learn how to check the given English alphabet is Upper case or Lower case
using Ascii value in Java language
Program 2
import java.util.Scanner;
public class Check_Upper_Lower1{
public static void main(String args[]){
char ch;//char variable declaration
Scanner scan=new Scanner(System.in);
//create a scanner object for user input
System.out.println("Enter a Alphabet only to check upper or lower: ");
ch=scan.next().charAt(0);;// reading the input from the user
if(ch>=65 && ch<=90){
System.out.println(ch+" is an upper case letter ");
}//check upper case Alphabe
else{
System.out.println(ch+" is a lower case letter ");
}//display the lower Alphabets
}
} when the above code is executed, it produces the following result
Case 1
Enter a Alphabet only to check upper or lower : A A is an Upper case letter
Case 2
Enter a Alphabet only to check upper or lower : s s is a Lower case letter
Suggested post
Nested if statements in Java language
Do-while loop in Java language
Similar post
Java program to print all alphabets in given range
C program to print all alphabets in given range
C++ program to print all alphabets in given range
Java program to print all alphabets using loops
C program to print all alphabets using loops
C++ program to print all alphabets using loops
Java program to check whether a character is Alphabet or Not
C++ program to check whether a character is Alphabet or Not
C program to check whether a character is Alphabet or Not
Python program to check whether a character is Alphabet or Not
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.