4.1) DEVELOP A PROGRAM TO CHECK SWITCH CASE USING INTEGER TYPE. PROGRAM: class no { public static void main(String args[]) { int a=10,b=20,c,n=2; switch(n) { case 1: c=a+b; System.out.println("sum="+c); break; case 2: c=a*b; System.out.println("mul="+c); break; case 3: c=a-b; System.out.println("sub="+c); break; case 4: c=a/b; System.out.println("div="+c); break; case 5: c=a%b; System.out.println("mod="+c); break;
default: System.out.println("Your case is improper..."); break; } } } OUTPUT:
4.2) DEVELOP A PROGRAM TO CHECK SWITCH CASE USING CHAR TYPE. PROGRAM: class hp { public static void main(String args[]) { char c='z'; switch(c) { case'a':
System.out.println("it is vowel"); break;
case'e': System.out.println("it is vowel"); break;
case 'i': System.out.println("it is vowel"); break;
case'o': System.out.println("it is vowel"); break;
case'u': System.out.println("it is vowel"); break;
case'A': System.out.println("it is vowel"); break;
case'E': System.out.println("it is vowel"); break;
case'I':
System.out.println("it is vowel"); break;
case'O': System.out.println("it is vowel"); break;
case'U': System.out.println("it is vowel"); break; default: System.out.println("it is a constraint"); break; } } }
OUTPUT: