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
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
Social Sciences,
15 days ago
Science,
15 days ago
Political Science,
1 month ago
Science,
9 months ago
Math,
9 months ago
Math,
9 months ago