-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain9.java
More file actions
28 lines (18 loc) · 722 Bytes
/
Main9.java
File metadata and controls
28 lines (18 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package ifelsejava;
import java.util.Scanner;
public class Main9 {
public static void main(String[] args) {
char ch;
Scanner input = new Scanner(System.in);
System.out.println("Input any character and check whether it is alphabet, digit or special characters.\n");
System.out.print("Enter a character: ");
ch = input.next().charAt(0);
if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') {
System.out.println(ch + " is alphabet.");
} else if(ch >= '0' && ch <= '9'){
System.out.println(ch + " is digit.");
} else {
System.out.println(ch + " is special character.");
}
}
}