Java Code to Convert Uppercase Character to Lowercase - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Monday, September 25, 2017

Java Code to Convert Uppercase Character to Lowercase

Write a Java Code to Convert Uppercase Character to Lowercase

Program:
/* Java Program Example - Convert Uppercase Character to 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 the character in Uppercase:B

Equivalent character in Lowercase:b

No comments:

Post a Comment