-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay-03-Java-Q16
More file actions
60 lines (43 loc) · 1.35 KB
/
Day-03-Java-Q16
File metadata and controls
60 lines (43 loc) · 1.35 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*Maya wants to know how to find whether the alphabet is Vowel or Consonant.could you please help her to find the alphabet is Vowel or Consonant.
Input Format
input consists of one Character.
Constraints
No Constraints
Output Format
print whether the character is Vowel or Consonant or Invalid Input.
Sample Input 0
A
Sample Output 0
The Character A is Vowel
Sample Input 1
B
Sample Output 1
The Character B is Consonant
Sample Input 2
u
Sample Output 2
The Character u is Vowel
Sample Input 3
9
Sample Output 3
Invalid Input*/
#Answer
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char ch = sc.next().charAt(0);
if (Character.isLetter(ch)) {
char lower = Character.toLowerCase(ch);
String result = (lower == 'a' || lower == 'e' || lower == 'i' ||
lower == 'o' || lower == 'u')
? "Vowel" : "Consonant";
System.out.println("The Character " + ch + " is " + result);
} else {
System.out.println("Invalid Input");
}
sc.close();
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
}
}