Skip to content

Commit

Permalink
VowelOrConsonant.java
Browse files Browse the repository at this point in the history
  • Loading branch information
gawadeatul authored Oct 17, 2023
1 parent b897d4a commit 75f2ce0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions VowelOrConsonant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.HashSet;
import java.util.Set;

public class VowelOrConsonant {
public static void main(String[] args) {
char ch = 'A';

Set<Character> vowels = new HashSet<>();
vowels.add('a');
vowels.add('e');
vowels.add('i');
vowels.add('o');
vowels.add('u');
vowels.add('A');
vowels.add('E');
vowels.add('I');
vowels.add('O');
vowels.add('U');

if (vowels.contains(ch)) {
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(ch + " is not a valid alphabet.");
}
}
}

0 comments on commit 75f2ce0

Please sign in to comment.