Professional Documents
Culture Documents
num=0, other=1
PROCESSING
REQUIRED
OUTPUT
SOURCE CODE:
import java.io.*;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class PowerOfTwo
{
public static void main(String args[]) throws IOException
{
String in;
in = JOptionPane.showInputDialog("Enter the number : ");
int num = Integer.parseInt(in);
int other = 1;
if(((~num) & 1) == 1)
{
JOptionPane.showMessageDialog(null, num + " is a Power of 2", "IDENTFYING
NUMBER IS A POWER OF 2",
JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null, num + " is not a Power of 2", "IDENTFYING
NUMBER IS A POWER OF 2",
JOptionPane.INFORMATION_MESSAGE);
}
}
}
SCREENSHOTS