Play audio slide show -- Keyboard shortcut: 'x'  Back to slide -- Keyboard shortcut: 'u'  next        Play sound for this slide -- Keyboard shortcut: 'y'  KarakterProgram.java - Et tilsvarende Java program.Lecture 3 - slide 9 : 39
Program 2

class KarakterProgram {

  static final int BESTAAET = 0;
  static final int IKKE_BESTAAET = 1;

  static final int NUL_NUL = 0;
  static final int NUL_TRE = 3;
  static final int FEM = 5;
  static final int SEKS = 6;
  static final int SYV = 7;
  static final int OTTE = 8;
  static final int NI = 9;
  static final int TI= 10;
  static final int ELLEVE = 11;
  static final int TRETTEN = 13;

  static int omsaet_karakter(int k){
    if (k <= FEM)
       return(IKKE_BESTAAET);
    else return(BESTAAET);
  }
  
  static void print_karakter(int k){
    switch (k){
     case BESTAAET: System.out.println("bestaaet"); break;
     case IKKE_BESTAAET: System.out.println("ikke_bestaaet"); break;
     default: throw new RuntimeException("Ikke eksisterende karakter");
    }
  }
  
  static void main(String[] args){
    print_karakter(omsaet_karakter(SYV));
    print_karakter(omsaet_karakter(FEM));
  }
}