Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.31 KB

File metadata and controls

38 lines (26 loc) · 1.31 KB

Exercise 3

In this task, you will use bitwise operators (&, |) along with if-else statements to make decisions based on the results of the operations. The goal is to practice using bitwise operations and conditional logic in Java.

  1. Input:

    • Accept two integer inputs from the user.
  2. Bitwise Operations:

    • Perform the bitwise AND (&) operation on the two integers.
    • Perform the bitwise OR (|) operation on the two integers.
  3. Conditional Logic:

    • If the result of the AND operation is greater than 10, print "AND result is greater than 10". Otherwise, print "AND result is less than or equal to 10".
    • If the result of the OR operation is a multiple of 4, print "OR result is a multiple of 4". Otherwise, print "OR result is not a multiple of 4".
import java.util.Scanner;

public class BitwiseOperations {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        // Input values
        System.out.print("Enter the first integer: ");
        int num1 = scanner.nextInt();
        
        System.out.print("Enter the second integer: ");
        int num2 = scanner.nextInt();
        // Bitwise Operations

        //If else block for >10


        //If else block for % 4
    }
}