import javax.swing.*;class dec_bin{ public static void main(String args[]){ String inp, bin; int dec, x; inp = JOptionPane.showInputDialog("Enter a Decimal Number:"); dec = Integer.parseInt(inp); bin = ""; while(dec != 0){ x = dec % 2; bin = x + bin; dec /= 2; } System.out.println("Binary: " + bin); }}
Comments
Post a Comment
share your thoughts ....