Comment utliser l’instruction ‘switch’: Exemple de voyelle et consonne

Author:


{filelink=4610}

public class VoyelleEtConsonne {
  public static void main(String[] args) {
    for(int i = 0; i < 100; i++) {
      char c = (char)(Math.random() * 26 + 'a');
      System.out.print(c + ": ");
      switch(c) {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u': System.out.println("voyelle");
                  break;
        case 'y':
        case 'w': System.out.println("Utilis� souvent comme voyelle");
                  break;
        default:  System.out.println("consonne");
      }
    }
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *