Java Program To Convert Hexadecimal To Decimal

Learn java program to convert hexadecimal to decimal.

Basically to convert a hexadecimal number to decimal number using manual calculation is quite hard. So in the java program below we areĀ leveraging two methods namely get_Value() and to_Convert() to do the conversion. The java program accepts value from the end user to do the conversion from hexadecimal to decimal. Let’s get into example,

Example: Java Program To Convert Hexadecimal To Decimal

Also ReadĀ – Decimal to Hexadecimal Java Program

import java.util.Scanner;

public class Hexa_To_Decimal {

int number;

void get_Value(){
System.out.println("Java Program To Convert Hexadecimal To Decimal");
Scanner sc = new Scanner(System.in);
System.out.println("Please enter number to convert: ");
number = Integer.parseInt(sc.nextLine(),16);
}

void to_Convert(){
String decimal = Integer.toString(number);
System.out.println("The Decimal value is: " + decimal);
}

public static void main(String[] args) {

Hexa_To_Decimal htd = new Hexa_To_Decimal();
htd.get_Value();
htd.to_Convert();

}
}

Output:

Java Program To Convert Hexadecimal To Decimal

About the author

admin

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *