- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to find whether given character is vowel or consonant
In English alphabet the characters 'a', 'e', 'i', 'o','u' are vowels and remaining letters are consonants. To find whether the given letter is a vowel or consonant.
Using loop and or operator verify whether given character is 'a' or 'e' or 'i' or 'o' or 'u' else it is consonant.
Example
import java.util.Scanner; public class VowelOrConsonant { public static void main(String args[]){ System.out.println("Enter a character :"); Scanner sc = new Scanner(System.in); char ch = sc.next().charAt(0); if(ch == 'a'|| ch == 'e'|| ch == 'i' ||ch == 'o' ||ch == 'u'||ch == ' '){ System.out.println("Given character is an vowel"); }else{ System.out.println("Given character is a consonant"); } } }
Output
Enter a character : a Given character is an vowel Enter a character : l Given character is a consonant
- Related Articles
- Java program to find whether given character is vowel or consonant using switch case
- C++ Program to Check Whether a character is Vowel or Consonant
- Java Program to Check Whether an Alphabet is Vowel or Consonant
- Program to find if a character is vowel or Consonant in C++
- Haskell Program to Check Whether an Alphabet is Vowel or Consonant
- Java program to find whether the given character is an alphabet or not
- Java program to find whether given number is even or odd
- Java program to find whether the given string is empty or null
- Java Program to Check Whether a Character is Alphabet or Not
- Alternate vowel and consonant string in C++
- Java program to check whether a given string is Heterogram or not
- Alternate vowel and consonant string in C/C++?
- C++ Program to Check Whether a Character is Alphabet or Not
- Haskell Program to Check Whether a Character is Alphabet or Not
- Check whether a character is Lowercase or not in Java

Advertisements