import java.util.Scanner;
class Hexa {
Scanner scan;
int num;
void getVal() {
scan = new Scanner(System.in);
System.out.println("\nEnter the number :");
num = Integer.parseInt(scan.nextLine(), 16);
}
void convert() {
System.out.println("HexaDecimal to Binary");
String binary = Integer.toBinaryString(num);
System.out.println("Binary Value is : " + binary);
System.out.println("HexaDecimal to Decimal");
String decimal = Integer.toString(num);
System.out.println("Decimal Value is : " + decimal);
System.out.println("HexaDecimal to Octal");
String octal = Integer.toOctalString(num);
System.out.println("Octal Value is : " + octal); }
}
class Main {
public static void main(String args[]) {
Hexa obj = new Hexa ();
obj.getVal();
obj.convert();
}
}
Output:
Enter the number :
78
HexaDecimal to Binary
Binary Value is : 1111000
HexaDecimal to Decimal
Decimal Value is : 120
HexaDecimal to Octal
Octal Value is : 170