Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- import java.util.Scanner;
- public class HexToDecimal {
- public static void main(String[] args) {
- System.out.print("Hexadecimal Input:");
- Scanner s = new Scanner(System.in);
- String inputHex = s.nextLine();
- try{
- Integer outputDecimal = Integer.parseInt(inputHex, 16);
- System.out.println("Decimal Equivalent : "+outputDecimal);
- }
- catch(NumberFormatException ne){
- System.out.println("Invalid Input");
- }
- finally{
- s.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement