Computer Science, asked by Anonymous, 4 months ago

Write a program in Java to input a character and check weather it is in uppercase or lowercase.​

Answers

Answered by amritpalkaur6840
2

1. Java Program to Check if given Alphabets are Uppercase or Lowercase or Digits

2.import java.io.BufferedReader;

3. import java.io.IOException;

4.import java.io.InputStreamReader;

5. public class Alphabet_Check.

6.public static void main(String args[]) throws IOException.

mark me Brainliest answer please

Answered by anindyaadhikari13
7

Required Answer:-

Question:

  • Write a program in Java to input a character and check whether it is in Upper case or lower case.

Solution:

Here comes the program.

import java.util.*;

public class Character {

 public static void main(String[] args) {

   Scanner sc=new Scanner(System.in);

   System.out.print("Enter a character: ");

   char ch=sc.next().charAt(0);

   if(ch >= 'A' && ch <= 'Z')

     System.out.print("Upper Case.");

   else if(ch >= 'a' && ch <= 'z')

     System.out.print("Lower Case.");

   else

     System.out.print("Not a Letter.");

   sc.close();

 }

}

Explanation:

  • There is no method to take a character as input. So, we will input character in the same way a word is taken as input and from that, the first character is extracted.
  • We will now check if the character is between A to Z or a to z. If the character is between A to Z, then it is in upper case. If the character is between a and z, then it is in loser case or else, the character is not a letter.

Sample I/O:

Enter a character: A

Upper Case.

Enter a character: b

Lower Case.

Enter a character: @

Not a letter.

Attachments:
Similar questions