-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEach_loop4.java
More file actions
30 lines (26 loc) · 817 Bytes
/
Copy pathEach_loop4.java
File metadata and controls
30 lines (26 loc) · 817 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
29
30
package loop;
import java.util.Scanner;
public class Each_loop4 {
public static void main(String[] args) {
boolean isVowel = false;
char ch;
try (Scanner scanner = new Scanner(System.in)) {
System.out.print("Enter a character : ");
ch = scanner.next().charAt(0);
}
switch(ch){
case 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U' -> isVowel = true;
}
if(isVowel == true){
System.out.println(ch+" is a Vowel");
}
else {
if(ch>='a' && ch <='z' || ch >='A' && ch <= 'z'){
System.out.println(ch+"is a Consonant");
}
else {
System.out.println("Input is not an alphabet");
}
}
}
}