UNB/ CS/ David Bremner/ teaching/ java/ CharExamples.java
public class CharExamples{
  
  public static void main(String[] args){

    System.out.println(parseHexDigit('E'));

    System.out.println(parseHexDigit('9'));

    System.out.println(parseHexDigit('L'));

  }


  static int parseHexDigit(char digit){
    
    if ( '0' <= digit  && digit <= '9' ){
      return digit-'0';
    } else if ('A' <= digit && digit <= 'E') {
      return digit -'A';
    } else {
      throw new IllegalArgumentException("Illegal hex digit: "+digit);
    }
  }
}