From dbfe6145471335753d18c4356b8f8d1b47a7e3e5 Mon Sep 17 00:00:00 2001 From: ayushk780 <40500298+ayushk780@users.noreply.github.com> Date: Fri, 16 Oct 2020 19:08:05 +0530 Subject: [PATCH 1/2] Create Bitwise.java --- Java/Bitwise-Operations/Bitwise.java | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Java/Bitwise-Operations/Bitwise.java diff --git a/Java/Bitwise-Operations/Bitwise.java b/Java/Bitwise-Operations/Bitwise.java new file mode 100644 index 0000000..70a1a36 --- /dev/null +++ b/Java/Bitwise-Operations/Bitwise.java @@ -0,0 +1,52 @@ +import java.io.*; + +public class Bitwise { + public static void main(String args[])throws IOException { + DataInputStream d=new DataInputStream(System.in); + System.out.println("enter value for x:"); + int x=Integer.parseInt(d.readLine()); + System.out.println("\n enter value for y:"); + int y= Integer.parseInt(d.readLine()); + int choice; + do { + System.out.println("**********************"); + System.out.println("1.Bitwise AND"); + System.out.println("2.Bitwise OR"); + System.out.println("3.Bitwise XOR"); + System.out.println("4.Bitwise LEFT SHIFT"); + System.out.println("5.Bitwise RIGHT SHIFT"); + System.out.println("6.Bitwise NOT"); + System.out.println("7.EXIT"); + System.out.println("***********************"); + System.out.println("enter your choice:"); + choice=Integer.parseInt(d.readLine()); + switch(choice) { + case 1: + System.out.println("Bitwise AND OPERATION:"+(x&y)); + break; + case 2: + System.out.println("Bitwise OR OPERATION:"+(x|y)); + break; + case 3: + System.out.println("Bitwise XOR OPERATION:"+(x^y)); + break; + case 4: + System.out.println("LEFT SHIFT:"+(x<>y)); + break; + case 6: + System.out.println("NOT of x :"+(~x)); + System.out.println("NOT of y :"+(~y)); + break; + case 7: + System.out.println("Thankyou"); + System.exit(1); + break; + default: + System.out.println("Invalid chioce, Please enter the correct choice"); + } + } while(choice!=7); + } +} From b47ed54cd68e131888cb7ea22761173419c604f7 Mon Sep 17 00:00:00 2001 From: ayushk780 <40500298+ayushk780@users.noreply.github.com> Date: Fri, 16 Oct 2020 19:08:25 +0530 Subject: [PATCH 2/2] Create README.md --- Java/Bitwise-Operations/README.md | 205 ++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 Java/Bitwise-Operations/README.md diff --git a/Java/Bitwise-Operations/README.md b/Java/Bitwise-Operations/README.md new file mode 100644 index 0000000..ddb58e2 --- /dev/null +++ b/Java/Bitwise-Operations/README.md @@ -0,0 +1,205 @@ +## Expected Output + +Enter value for x: + +4 + + + +Enter value for y: + +2 + +********************** + +1.Bitwise AND + +2.Bitwise OR + +3.Bitwise XOR + +4.Bitwise LEFT SHIFT + +5.Bitwise RIGHT SHIFT + +6.Bitwise NOT + +7.EXIT + +*********************** + +enter your choice: + +1 + +Bitwise AND OPERATION:0 + +********************** + +1.Bitwise AND + +2.Bitwise OR + +3.Bitwise XOR + +4.Bitwise LEFT SHIFT + +5.Bitwise RIGHT SHIFT + +6.Bitwise NOT + +7.EXIT + +*********************** + +enter your choice: + +2 + +Bitwise OR OPERATION:6 + +********************** + +1.Bitwise AND + +2.Bitwise OR + +3.Bitwise XOR + +4.Bitwise LEFT SHIFT + +5.Bitwise RIGHT SHIFT + +6.Bitwise NOT + +7.EXIT + +*********************** + +enter your choice: + +3 + +Bitwise XOR OPERATION:6 + +********************** + +1.Bitwise AND + +2.Bitwise OR + +3.Bitwise XOR + +4.Bitwise LEFT SHIFT + +5.Bitwise RIGHT SHIFT + +6.Bitwise NOT + +7.EXIT + +*********************** + +enter your choice: + +4 + +LEFT SHIFT:16 + +********************** + +1.Bitwise AND + +2.Bitwise OR + +3.Bitwise XOR + +4.Bitwise LEFT SHIFT + +5.Bitwise RIGHT SHIFT + +6.Bitwise NOT + +7.EXIT + +*********************** + +enter your choice: + +5 + +RIGHT SHIFT:1 + +********************** + +1.Bitwise AND + +2.Bitwise OR + +3.Bitwise XOR + +4.Bitwise LEFT SHIFT + +5.Bitwise RIGHT SHIFT + +6.Bitwise NOT + +7.EXIT + +*********************** + +enter your choice: + +6 + +NOT of x :-5 + +NOT of y :-3 + +********************** + +1.Bitwise AND + +2.Bitwise OR + +3.Bitwise XOR + +4.Bitwise LEFT SHIFT + +5.Bitwise RIGHT SHIFT + +6.Bitwise NOT + +7.EXIT + +*********************** + +enter your choice: + +8 + +Invalid chioce, Please enter the correct choice + +********************** + +1.Bitwise AND + +2.Bitwise OR + +3.Bitwise XOR + +4.Bitwise LEFT SHIFT + +5.Bitwise RIGHT SHIFT + +6.Bitwise NOT + +7.EXIT + +*********************** + +enter your choice: + +7 + +Thankyou