package review;
import java.util.*;
public class Test{
public static void main(String[]args) {
Scanner input = new Scanner(System.in) ;
System.out.println("输入要求十六进制的数 ");
int sum = input.nextInt() ;
String hex= " " ;
while (sum != 0 ) { // 输入数字不能为零
int hexValue = sum % 16 ; //取余数
char hexDigit = (char) ((hexValue <= 9 && hexValue != 0) ? //通过对余数的判断来决定
(hexValue+ '0' ) : (hexValue - 10 + 'A' )) ;
hex = hexDigit + hex ;
sum = sum / 16 ;
}
System.out.println("16进制是: " + hex);
}
}