Here is Program to find whether entered character is a vowel constant number or a special character
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import java.io.*; class stch { public static void main(String [] args) throws IOException { char ch; DataInputStream din= new DataInputStream(System.in); System.out.println( "Enter the character: " ); ch=( char )(din.read()); switch (ch) { case 'a' : case 'e' : case 'i' : case 'o' : case 'u' : { System.out.println( "The character character is a Vowel." ); break ; } case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : { System.out.println( "The character entered is a Number." ); break ; } case 'v' : case 'n' : case 't' : case 'b' : case 'r' : case 'f' : { System.out.println( "The character entered is a Special Character." ); break ; } default : { System.out.println( "The character entered is Constant." ); break ; } } } } |
how do u deal with special chars like @#$ in switch case??
how do u deal with special chars like @#$ in switch case??