import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner Tec = new Scanner (System.in);
System.out.println("Introduce el numero que quieres en hexadecimal:");
int Decimal = Tec.nextInt();
String Hexadecimal = "";
while (Decimal>0){
int HexBit = Decimal%16;
String Hex10;
if (HexBit<10){
Hexadecimal=HexBit+Hexadecimal;
}else{
switch(HexBit){
case 10: Hex10="A";break;
case 11: Hex10="B";break;
case 12: Hex10="C";break;
case 13: Hex10="D";break;
case 14: Hex10="E";break;
default: Hex10="F";
}
Hexadecimal = Hex10+Hexadecimal;
}
Decimal = Decimal/16;
}
System.out.println ( "El numero en binario es: "+Hexadecimal);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: