Program to take input a character and convert into its opposite case. Print the original character and new character.
import
java.util.*;
class Case
{
public static void main()
{
Scanner Sc=new Scanner(System);
System.out.println(“Enter a character:” );
char c=Sc.nextChar();
char d;
if(Character.isUpperCase(c)==true)
{ d=c.toLowerCase(); }
if(Character.isUpperCase(c)==true)
{ d=c.toLowerCase(); }
{ System.out.println(“Original character: “+c); }
{ System.out.println(“New character: “+d); }
} }
class Case
{
public static void main()
{
Scanner Sc=new Scanner(System);
System.out.println(“Enter a character:” );
char c=Sc.nextChar();
char d;
if(Character.isUpperCase(c)==true)
{ d=c.toLowerCase(); }
if(Character.isUpperCase(c)==true)
{ d=c.toLowerCase(); }
{ System.out.println(“Original character: “+c); }
{ System.out.println(“New character: “+d); }
} }
Output: Enter a
character: A
Original character: A
New
character: aOriginal character: A
No comments: