import java.util.Scanner;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        Scanner tec =new scanner(System.in)
        //Entrada de datos
        System.out.println("Introduce un nmero en hexadecimal: ");
        String hex = tec.next();
        tec.close();
        int decimal=0;
        for(int i=0; i < hex.lenght(); i++){
            String cifra = hex.substring (i,i+1);
            int vcifra;
            switch (cifra.toUppercCase()) {
                case A: vcifra=10; break;
                case B: vcifra=10; break;
                case C: vcifra=10; break;
                case D: vcifra=10; break;
                case E: vcifra=10; break;
                case F: vcifra=10; break;
                default: vcifra =Integer.parseInt(cifra);        
            }
        decimal = decimal + vicfra*(int)Math.pow(16,hex.lenght()-1-i);
        System.out.println(decimal);
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: