Write a Program in Java to Check if a Character is an Uppercase Vowel or Lowercase Vowel or Not
In this program, we are going to check whether a user-inputted alphabet is in an uppercase vowel or in a lowercase vowel or not. The file name is MyVowelCheck.java so the main class name is MyVowelCheck. Here I'm using the Scanner class to receive user-inputted character values.
To check whether the input is a proper alphabet or some special character, or to check whether it is in uppercase or in lowercase, we have to determine the ASCII value of that given character. By the use of ASCII values, we can say our desired result.
To get the ASCII value of the character, we have to typecase the variable in integer format. The int value of a char variable returns the ASCII value associated with it.
Now there is a range in ASCII values to obtain inputted character is an alphabet or not. The ASCII range for the lowercase alphabets is between 65 to 90 and the ASCII range for the uppercase alphabets is between 97 to 122. After checking the range we have to check for the ASCII values of a,e,i,o,u vowels from the English alphabet sets. As per the corresponding ASCII value, we have to print whether the inputted alphabet is an uppercase vowel or a lowercase vowel or not.
Filename:- MyVowelCheck.java
0 Comments