Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
C++ program: Check whether the given Alphabet is upper or lower case

Program to check if given alphabet is upper or lower case in Java

Posted on March 29, 2022

Table of Contents

  • Program to check if given alphabet is upper or lower case in Java
    • Code to check given Alphabet is Upper or Lower
      • Code to check given Alphabet is Upper or Lower, using  if  else
      • Code to check given Alphabet is Upper or Lower, using Ascii

Program to check if given alphabet is upper or lower case in Java

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

Code to check given Alphabet is Upper or Lower

Code to check given Alphabet is Upper or Lower, using  if  else

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

 

Code to check given Alphabet is Upper or Lower, using Ascii

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

if statement in Java language

Nested if statements in Java language

Method in Java language

For loop in Java language

While loop in Java language

Do-while loop in Java language

Operator in Java language

Variable in Java language

Data type in Java language

class and main method in Java

 

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

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes