Write a Java-program to check the given character is symbol letter or not

Write a Java-program to check the given character is symbol letter or not

Program
public class Main
{
    public static void main(String args[])
    {
        char ch='#';
        if(!(ch>='0' && ch<='9' || ch>='a' && ch<='z' || ch>='A' && ch<='Z'))
        {
            System.out.println("Symbol");
        }
        else
        {
            System.out.println("Not a Symbol");
        }
    }
}	

Output:

Symbol

Using CommandLine Arguments
public class Main
{
    public static void main(String args[])
    {
        char ch;
        ch=args[0].charAt(0);
        if(!(ch>='0' && ch<='9' || ch>='a' && ch<='z' || ch>='A' && ch<='Z'))
        {
            System.out.println("Symbol");
        }
        else
        {
            System.out.println("Not a Symbol");
        }
    }
}	

Output:

Symbol

Using Scanner Class
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        char ch;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter character");
        ch=s.next().charAt(0);
        if(!(ch>='0' && ch<='9' || ch>='a' && ch<='z' || ch>='A' && ch<='Z'))
        {
            System.out.println("Symbol");
        }
        else
        {
            System.out.println("Not a Symbol");
        }
    }
}	

Output:

Enter character
#
Symbol





More Questions


33 . Write a Java-program to check the given character is number or not
34 . Write a Java-program to check the given character is symbol letter or not
35 . Write a Java-program to calculate simple interest with following condtions
36 . Write a Java-program to print age
37 . Write a Java-program to print Max Number amoung the three numners using else if
38 . Write a Java-program to check the given character is vowel or consonant( Character must be small letter)
39 . Write a Java-program to check Odd or Even number program using nested if condition(value must be positive)
40 . Write a Java-program to check Odd or Even number using switch
41 . Write a Java-program to check Vowel or Consonant using switch
42 . Write a Java-program to display 1 to 10 values using for loop
43 . Write a Java-program to display 10 to 1 values using for loop