-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaseCheck.java
More file actions
25 lines (19 loc) · 856 Bytes
/
Copy pathCaseCheck.java
File metadata and controls
25 lines (19 loc) · 856 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
// Q: Write a Java program that reads a single character and determines whether it is a lowercase letter,
//uppercase letter, or not an alphabetic letter.
import java.util.Scanner;
public class CaseCheck {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// System.out.println(in.next().trim());
// trim() removes any leading or trailing whitespace, ie: that it removes any extra spaces before or after the character input
char ch = in.next().trim().charAt(0);
if (ch >= 'a' && ch <= 'z') {
System.out.println("Lowercase Letter");
} else if (ch >= 'A' && ch <= 'Z') {
System.out.println("Uppercase Letter");
} else {
System.out.println("Not an Alphabetic Letter");
}
System.out.println(ch);
}
}