Find character case
Write a program to determine whether the entered character is in uppercase or lowercase, or is an invalid character.
Input format :
Output format :
Sample Input 1 :
Sample Output 1 :
Sample Input 2 :
Sample Output 2 :
Sample Input 3 :
Sample Output 3 :
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner s = new Scanner (System.in);
char chr = s.next().charAt(0);
if(chr >= 'A' && chr <= 'Z')
{
System.out.println("1");
}
else if ( chr >='a' && chr <='z')
{
System.out.println("0");
}
else
{
System.out.println("-1");
}
}
}
No comments:
Post a Comment