Write a program to accept a character from the terminal window and determine whether it is a letter or not. if it is an alphabet, display its opposite case. if it is not an alphabet, display an appropriate message. Write a program to accept a character from the terminal window and determine whether it is a letter or not. if it is an alphabet, display its opposite case. if it is not an alphabet, display an appropriate message.
Answers
Answered by
15
Import java.util.*;
public class Check
{Scanner sc= new Scanner( System.in);
public void main()
{
System.out.println(“Enter the characher”);
char ch= sc.next().chatAt(0);
if(Character.isLetter(ch))
{
if(Character.isUpperCase(ch))
System.out.println(ch+" opposite case is "+ Character.toLowerCase(ch));
else
System.out.println(ch+ " opposite case is " +Character.toUpperCase(ch));
}
else
System.out.println(ch+" is not a letter");
}
}
Similar questions