package convertpkg;

public class ConvertHex {
  public static int transHex(char c) {
     if (Character.isDigit(c)) return (int)(c - '0');
     else if (c == 'A' || c == 'a') return 10;
     else if (c == 'B' || c == 'b') return 11;
     else if (c == 'C' || c == 'c') return 12;
     else if (c == 'D' || c == 'd') return 13;
     else if (c == 'E' || c == 'e') return 14;
     else if (c == 'F' || c == 'f') return 15;
     else {
       System.exit(1);
       return -1;
     }
  }

  public static void main(String[] args) {
    GetNext getNext = new GetNext();
    int num = 0;
    char ch = getNext.getNextChar();
    while (!(ch == ' ' || ch == '\n')) {
      num = num*16 + transHex(ch);
      System.out.println("ch: " + ch + ", num: " + num);
      ch = getNext.getNextChar();
    }
    System.out.println(num);
  }
}


