Octal to hexadecimal conversion program in java

Octal to hexadecimal conversion program in java. In a Java program, convert an octal number to a hexadecimal number. This isn’t your typical octal to hexadecimal converter. The octal numeral system, also known as oct, is a base-8 numbering system that employs the digits 0 through 7. By grouping consecutive binary digits into groups of three, octal numerals can be generated from binary numerals. Relating to or using a system of numerical notation with a foundation of 16 rather than 10.

import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
String octalnumber, hexadecimal;
int decimalnum;
Scanner scan = new Scanner(System.in);
System.out.print("Enter Octal Number ");
octalnumber = scan.nextLine();
decimalnum = Integer.parseInt(octalnumber, 8);
hexadecimal = Integer.toHexString(decimalnum);
System.out.print("Hexadecimal Value of " + octalnumber + " is :\n");
System.out.print(hexadecimal);
}
}

 

Output:

Enter Octal Number : 56 Equivalent Hexadecimal Value of 56 is : 2e

Hexadecimal function in java program

The Hexadecimal Number System is a type of numerical representation with the number 16 as the base number. That means there are only 16 possible digit values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Only four bits are required to express the value of any digit.

Octal function in java program

The octal numeral system, sometimes known as oct, is a base-8 numbering system that use the numerals 0 through 7. By arranging consecutive binary digits into groups of three, octal numerals can be created from binary numerals (starting from the right). The binary representation of decimal 74, for example, is 1001010.