Skip to content

Instantly share code, notes, and snippets.

@pawitp
Created February 9, 2012 14:58
Show Gist options
  • Save pawitp/1780483 to your computer and use it in GitHub Desktop.
Save pawitp/1780483 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class HexToDecWithBonus {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter hex: ");
int dec = in.nextInt(16);
System.out.println("Decimal: " + dec);
System.out.println("Binary: " + Integer.toBinaryString(dec));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment