Version without JavaScript, read-only: workshops, quizzes and running code are not available here. Full version · Catalogue · Sign in

Sequence

Vowel or consonant (switch)

Core exercise

Write typeLettre(char c) that returns "voyelle" (vowel) or "consonne" (consonant), using a switch. The vowels are taken to be a e i o u y, in lower case.

A workshop goes here: you write and run code in it. It requires JavaScript.

Starting code

Exercices.java

public class Exercices {

    public static void main(String[] args) {
        System.out.println("a : " + typeLettre('a'));
        System.out.println("b : " + typeLettre('b'));
    }

    public static String typeLettre(char c) {
        // TODO : un switch sur c
        return "";
    }
}

The core exercise is validated in the workshop, which requires JavaScript.

Hint 1

Several cases can share the same treatment by stacking them without break: case 'a': case 'e': …. It is the only fall-through that is intentional.