25 Jul Java Playing with The Bits & Hide the Number Programming Project
Part 1 Playing with the bits.
Get the source from A3.java
Get a sample image sample.png
- What you need to do: Look for the instructions in the source code.
- Here is how the output image should look like: out.png (attached in the zip file)
- Part 2 (. Hide the number.
Write a program that asks the user for a number (an integer). Then your program loads a png image and hides the number in the image using the LSB method.
Write another program that loads an image in which a number has been hidden. Then retrieve and display the hidden number.
The following program iterates through each bit of a number, from the most significant bit to least significant bit.
import java.util.Scanner;
public class A {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print(“Please give me a number: “);
int N = in.nextInt();
System.out.println(“nAn integer is ” + Integer.SIZE + ” bits long.n”);
for(int i=Integer.SIZE-1; i >= 0; i– ) {
int b = (N >> i) & 0x01;
System.out.print(b + ” “);
}
System.out.println();
}
}
