Computer Science, asked by osama2749, 1 month ago

Write a Java program to accept a character and check the case (upper/lower) otherwise, check whether it is a digit or a special character . Sample input : Enter a character K Sample Output : K is an upper case character​

Answers

Answered by ItzMeSam35
4

import java.util.*;

public class UL

{

public static void main (String args[])

{

Scanner sc=new Scanner (System.in);

System.out.println("Enter A Character");

char ch = sc.next().charAt(0);

if ( ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f' || ch == 'g' || ch == 'h' || ch == 'i' || ch = 'j' || ch == 'k' || ch == 'l' || ch == 'm' || ch == 'n' || ch == 'o' || ch == 'p' || ch == 'q' || ch == 'r' || ch == 's' || ch == 't' || ch == 'u' || ch == 'v' ch == 'w' || ch == 'x' || ch == 'y' || ch == 'z' )

{

System.out.println("Character "+ch+" is a lower case");

}

else if ( ch == 'A' || ch == 'B' || ch == 'C' || ch == 'D' || ch == 'E' || ch == 'F' || ch == 'G' || ch == 'H' || ch == 'I' || ch = 'J' || ch == 'K' || ch == 'L' || ch == 'M' || ch == 'N' || ch == 'O' || ch == 'P' || ch == 'Q' || ch == 'R' || ch == 'S' || ch == 'T' || ch == 'U' || ch == 'V' ch == 'W' || ch == 'X' || ch == 'Y' || ch == 'Z' )

{

System.out.println("Character "+ch+" is a upper case ");

}

if ( ch == '~' || ch == '`' || ch == '!' || ch == '@' || ch == '#' || ch == '$' || ch == '%' || ch == '^' || ch == '&' || ch = '*' || ch == '(' || ch == ')' || ch == '-' || ch == '_' || ch == '+' || ch == '=' || ch == '{' || ch == '}' || ch == '[' || ch == ']' || ch == '|' || ch == '/' ch == ':' || ch == '"' || ch == '<' || ch == '>' || ch == ',' || ch == '.' || ch == '?')

{

System.out.println("Character "+ch+" is a special character");

}

else

{

System.out.println("Character "+ch+" is not a character");

}

sc.close();

}

}

// Please Mark As Brainiliest

Similar questions