forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVowels.java
More file actions
46 lines (38 loc) · 1.13 KB
/
Vowels.java
File metadata and controls
46 lines (38 loc) · 1.13 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
/**
* Example switch statement with cases that fall through.
*/
public class Vowels {
public static void main(String[] args) {
String s = "Ahoy!";
for (int i = 0; i < s.length(); i++) {
// display the next character
char c = s.charAt(i);
System.out.print(c + " is a ");
// if capital, convert to lowercase
if (c >= 'A' && c <= 'Z') {
c += 'a' - 'A';
}
// check if not a lowercase letter
if (c < 'a' || c > 'z') {
System.out.println("symbol");
continue;
}
// output the result of the letter
switch (c) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
System.out.println("vowel");
break;
case 'y':
System.out.println("not sure");
break;
default:
System.out.println("consonant");
break;
}
}
}
}