import java.util.Scanner;
public class Trans16_10 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String string = null;
// 注意 hasNext 和 hasNextLine 的区别
while (scanner.hasNext()) { // 注意 while 处理多个 case
string = scanner.next();
System.out.println("当前读取到为:" + string);
int ans = 0;
int length = string.length();
for (int i = length - 1; i > 1; i--) {
ans = (int) (ans + chatInt(string.charAt(i)) * (Math.pow(16, length - i - 1)));
//Math.pow(a,b):a^b.返回值为double,强转为int
System.out.println("当前数字乘以16后的结果:" + ans);
}
System.out.println(ans);
}
}
private static int chatInt(char c) {
System.out.println("当前字母为:" + c);
if ((c >= '0') && (c <= '9')) {
return c - '0';
} else {
int num = c - 'A' + 10;
System.out.println("当前字母代表的数字为:" + num);
return num;
}
}
}