Computer Science, asked by ishitasinghis071, 1 month ago

Write a java program to input a character and print if it is a digit or alphabet
or any special character (using “if” statement)

Answers

Answered by safashamon567
2

import java.util.*;

public class java

{

   public void display()

   {

       Scanner sc = new Scanner (System.in);

       System.out.println("Enter a character");

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

       if(ch>='0' && ch<='9')

       System.out.println(ch+" is a digit");

       else if(ch>='a' && ch<='z')

       System.out.println(ch+" is an alphabet");

       else if(ch>='A' && ch<='Z')

       System.out.println(ch+" is an alphabet");

       else

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

   }

}

Similar questions