Java Practical No.4.pdf

  • Uploaded by: Meer Kukreja
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Java Practical No.4.pdf as PDF for free.

More details

  • Words: 146
  • Pages: 5
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:

Related Documents


More Documents from "Meer Kukreja"