Syntax
import java.*; import java.io.*; import java.util.*; class switch_case { public static void main(String arg[]) { // Arithmetical opration perform using switch case Scanner sc = new Scanner(System.in); System.out.println("Enter Two Numbers : "); int n1 = sc.nextInt(); int n2 = sc.nextInt(); System.out.println("Press 1. add\n2. sub\n3. mul\n4. div\n\nEnter Your Choice Number : "); int ch = sc.nextInt(); switch(ch) { case 1: { int re = n1 + n2; System.out.println("Addition is "+re); break; } case 2: { int re = n1 - n2; System.out.println("Subtraction is "+re); break; } case 3: { int re = n1 * n2; System.out.println("Multiplication is "+re); break; } case 4: { int re = n1 / n2; System.out.println("Division is "+re); break; } default: System.out.println("Your Choice is Wrong!!!"); } } }
OUTPUT

Enter Two Numbers : 10 20 Press 1. add 2. sub 3. mul 4. div Enter Your Choice Number : 1 Addition is 30

Leave a Reply

Subscribe to Posts | Subscribe to Comments

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA