Java: Find Vowel or Consonant
Check Vowel or Consonant
Write a Java program that requires the user to enter a single character from the alphabet. Print Vowel or Consonant, depending on user input. If the user input is not a letter (between a and z or A and Z), or is a string of length > 1, print an error message.
Test Data
Input an alphabet: p
Pictorial Presentation:
Sample Solution:
Java Code:
Sample Output:
Input an alphabet: P Input letter is Consonant
Flowchart:
Java Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Java program to find the number of days in a month.
Next: Write a Java program that takes a year from user and print whether that year is a leap year or not.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics