Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class HexToBinary {
- Scanner scan;
- int num;
- void getVal() {
- System.out.println("HexaDecimal to Binary");
- scan = new Scanner(System.in);
- System.out.println("\nEnter the number :");
- num = Integer.parseInt(scan.nextLine(), 16);
- }
- void convert() {
- String binary = Integer.toBinaryString(num);
- System.out.println("Binary Value is : " + binary);
- }
- public static void main(String args[]) {
- HexToBinary obj = new HexToBinary();
- obj.getVal();
- obj.convert();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement