From 2fc0338caa4fd6288d4bc9d4de6bae4e54acbb91 Mon Sep 17 00:00:00 2001 From: VigyatBansal <63166899+VigyatBansal@users.noreply.github.com> Date: Thu, 1 Oct 2020 17:52:42 +0530 Subject: [PATCH] Update vowel.java --- programs/vowel.java | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/programs/vowel.java b/programs/vowel.java index 2267a51..6111348 100644 --- a/programs/vowel.java +++ b/programs/vowel.java @@ -1,34 +1,23 @@ import java.util.Scanner; class Vowel { - public static void main() + public static void main() throws Exception { - boolean isVowel=false;; Scanner sc=new Scanner(System.in); System.out.println("Enter a character : "); char ch=sc.next().charAt(0); - sc.close(); - switch(ch) - { - case 'a' : - case 'e' : - case 'i' : - case 'o' : - case 'u' : - case 'A' : - case 'E' : - case 'I' : - case 'O' : - case '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("Input is not an alphabet"); - } - } -} \ No newline at end of file + + char ch=Character.toUpperCase(ch); + if(ch == 'A'||ch == 'E'||ch == 'I'||ch == 'O'||ch =='U') + System.out.println("It is a Vowel"); + + else if((ch != 'A'||ch != 'E'||ch != 'I'||ch != 'O'||ch != 'U')&& Character.isLetter(ch)==true) + System.out.println("It is a Consonant."); + else + System.out.println("It is a Special Character."); + + + + + } +}