-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChar.java
32 lines (23 loc) · 924 Bytes
/
Char.java
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
29
30
31
32
/*
* Author : Murali Krishna Mallela
* Roll Number : 21C51A0522
* Date : 26/09/2024
*/
import java.util.Scanner;
public class Char {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a single character: ");
char userChar = scanner.next().charAt(0); // Read the first character
if (Character.isUpperCase(userChar)) {
System.out.println(userChar + " is an uppercase letter.");
} else if (Character.isLowerCase(userChar)) {
System.out.println(userChar + " is a lowercase letter.");
} else if (Character.isDigit(userChar)) {
System.out.println(userChar + " is a digit.");
} else {
System.out.println(userChar + " is not an uppercase letter, lowercase letter, or digit.");
}
scanner.close();
}
}