We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c9e4bde commit fad746bCopy full SHA for fad746b
1 file changed
ch09/Vowels.java
@@ -0,0 +1,42 @@
1
+public class Vowels {
2
+
3
+ public static void main(String[] args) {
4
+ String s = "Ahoy!";
5
+ for (int i = 0; i < s.length(); i++) {
6
7
+ // display the next character
8
+ char c = s.charAt(i);
9
+ System.out.print(c + " is a ");
10
11
+ // if capital, convert to lowercase
12
+ if (c >= 'A' && c <= 'Z') {
13
+ c += 'a' - 'A';
14
+ }
15
16
+ // check if not a lowercase letter
17
+ if (c < 'a' || c > 'z') {
18
+ System.out.println("symbol");
19
+ continue;
20
21
22
+ // output the result of the letter
23
+ switch (c) {
24
+ case 'a':
25
+ case 'e':
26
+ case 'i':
27
+ case 'o':
28
+ case 'u':
29
+ System.out.println("vowel");
30
+ break;
31
32
+ case 'y':
33
+ System.out.println("not sure");
34
35
36
+ default:
37
+ System.out.println("consonant");
38
39
40
41
42
+}
0 commit comments