Tuesday, August 16, 2011
Using JOptionPAne Converter for Binary To Hexadecimal
import javax.swing.JOptionPane;
import java.io.*;
import java.lang.*;
public class BinaryToHexadecimal {
public static void main(String[] args){
String hex;
hex = JOptionPane.showInputDialog(null, "Enter the Binary number:");
long num = Long.parseLong(hex);
long rem;
while(num > 0){
rem = num % 10;
num = num / 10;
if(rem != 0 && rem != 1){
JOptionPane.showMessageDialog(null, "This is not a binary number.","a", JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog(null, "Please try once again.","w", JOptionPane.WARNING_MESSAGE);
System.exit(0);
}
}
int i= Integer.parseInt(hex,2);
String hexString = Integer.toHexString(i);
JOptionPane.showMessageDialog(null, "Hexa decimal: " + hexString,"result", JOptionPane.INFORMATION_MESSAGE);
}
}
Subscribe to:
Post Comments (Atom)
MGM Resorts Casino, LLC v. MGM Resorts, LLC | DrmCD
ReplyDeleteof casinos and entertainment in the United States to be 양주 출장마사지 utilized MGM 경기도 출장샵 Resorts Casino, LLC v. 보령 출장마사지 MGM 순천 출장마사지 Resorts, 여수 출장마사지 LLC.