@@ -0,0 +1,572 @@
+import java.util.Scanner;%0A%0Apublic class CountBitPairs %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner scan = new Scanner(System.in);%0A        int n = scan.nextInt();%0A        System.out.println(countBitPairs(n));%0A    %7D%0A%0A    public static int countBitPairs(int n) %7B%0A        int count = 0;%0A        int previous = n & 1;%0A        int i;%0A        n %3E%3E= 1;%0A%0A        while (n %3E 0) %7B%0A            i = n & 1;%0A            if (i == previous) %7B%0A                count++;%0A            %7D%0A            previous = i;%0A            n %3E%3E= 1;%0A        %7D%0A%0A        return count;%0A    %7D%0A%7D%0A

Solve homework2-problem8: Count of Equal Bit Pairs