Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*program to implement nested switch case
- Input Output
- 0 0 0
- 0 1 1
- 1 0 2
- 1 1 3
- */
- /*
- Example:
- Enter boolean value with space.....
- 1 1
- Value is 3
- */
- import java.util.Scanner;
- class MainClass{
- public static void main(String arg[])
- {
- int a,b;
- Scanner input=new Scanner(System.in);
- System.out.println("\nEnter boolean value with space.....");
- a=input.nextInt();
- b=input.nextInt();
- switch(a)
- {
- case 0:
- switch(b)
- {
- case 0:
- System.out.println("Value is 0");
- break;
- case 1:
- System.out.println("Value is 1");
- break;
- }
- break;
- case 1:
- switch(b)
- {
- case 0:
- System.out.println("Value is 2");
- break;
- case 1:
- System.out.println("Value is 3");
- break;
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement