Java code to Convert Lowercase to Uppercase - 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 Lowercase to Uppercase

Write a Java code to Convert Lowercase to Uppercase

Program:
/* Java Program Example - Convert Lowercase Character to Uppercase */

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 Lowercase : ");
ch = scan.next().charAt(0);

temp = (int) ch;
temp = temp - 32;
ch = (char) temp;

System.out.print("Equivalent Character in Uppercase = " +ch);
}
}

Output:
Enter the character in Lowercase:b

Equivalent character in Uppercase:B

No comments:

Post a Comment