-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExp_9.java
More file actions
26 lines (22 loc) · 809 Bytes
/
Exp_9.java
File metadata and controls
26 lines (22 loc) · 809 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
import java.util.Scanner;
public class CheckVowel {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a single character: ");
char inputChar = sc.next().charAt(0); // Read user's input as a string and extract its first character
boolean isVowel = false;
switch (inputChar) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
isVowel = true;
break;
default:
isVowel = false;
}
String result = isVowel ? "The character '" + inputChar + "' is a vowel." : "The character '" + inputChar + "' is NOT a vowel.";
System.out.println(result);
}
}