Java Program

Object:-Write a Program in java to convert uppercase character into lowercase.

import java.util.Scanner;
public class JavaProgram
{
 public static void main(String[] input)
 {
  char ch;
  int temp;
  Scanner scan = new Scanner(System.in);        
  System.out.print("Enter a Character in Uppercase : ");
  ch = scan.next().charAt(0);                
  temp = (int) ch;
  temp = temp + 32;
  ch = (char) temp;               
  System.out.print("Equivalent Character in Lowercase = " + ch);
 }
}

Output

Enter a Character in Uppercase :C
Equivalent Character in Lowercase = c
 

Explanation

To convert uppercase character to lowercase character, you have to ask to the user to enter the character in uppercase to convert it into lowercase to display the equivalent character in lowercase. To change uppercase character into lowercase character, just add 32 in the character to convert it into lowercase. Since ASCII value of A is 65 and ASCII value of a is 97, so 65+32 = 97 = a = equivalent value of A in lowercase i.e., a








You may also like: