-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvowelChecker.java
23 lines (21 loc) · 926 Bytes
/
vowelChecker.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
public class vowelChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a single character: ");
char ch = scanner.next().charAt(0);
// Check if the character is an alphabet character
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
// Check if the character is a vowel
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') {
System.out.println(ch + " is a vowel.");
} else {
System.out.println(ch + " is a consonant.");
}
} else {
// If it's not an alphabet character, it's invalid input
System.out.println(ch + " is not a valid alphabet character.");
}
}
}