Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class HexToBinary {
  4.  
  5. Scanner scan;
  6. int num;
  7.  
  8. void getVal() {
  9.  
  10. System.out.println("HexaDecimal to Binary");
  11. scan = new Scanner(System.in);
  12.  
  13. System.out.println("\nEnter the number :");
  14. num = Integer.parseInt(scan.nextLine(), 16);
  15. }
  16.  
  17. void convert() {
  18.  
  19. String binary = Integer.toBinaryString(num);
  20.  
  21. System.out.println("Binary Value is : " + binary);
  22. }
  23.  
  24. public static void main(String args[]) {
  25.  
  26. HexToBinary obj = new HexToBinary();
  27.  
  28. obj.getVal();
  29. obj.convert();
  30.  
  31.  
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement