Output:
Click Here For Java Online Compiler
Solution:
*** Check Whether A Character Is Vowel Or Consonant *** Enter a single character : A "A" is a Vowel ----------------------------------------------------------- *** Check Whether A Character Is Vowel Or Consonant *** Enter a single character : R "R" is a Consonant ----------------------------------------------------------- *** Check Whether A Character Is Vowel Or Consonant *** Enter a single character : 68 Please enter an alphabetic character!!!
Click Here For Java Online Compiler
Solution:
import java.util.Scanner; public class VowelOrConsonantUsingIf { public static void main(String[] arg) { boolean isVowel = false; Scanner sc = new Scanner(System.in); System.out.println("*** Check Whether A Character Is Vowel Or Consonant ***" + "\n"); System.out.print("Enter a single character : "); char ch = sc.next().charAt(0); if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') { isVowel = true; } if (isVowel == true) { 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("Please enter an alphabetic character!!!"); } } } }
comment 1 comments:
more_vertnice article in your blog.thank you for sharing useful info.
29 August 2018 at 20:24visit
web programming tutorial
welookups
sentiment_satisfied Emoticon