mardi 28 mars 2017

If user input is not equal to

I am new to java and I am having difficulties impliying an error message when the user does not input the correct medium.

Here is my code

    medium air, water, steel;

    int mediumInput = medium.toLowerCase().length();

    if (medium != 'air' && medium != 'water' && medium != 'steel'){
        System.out.println("Invalid medium.");
        return;

    }

Aucun commentaire:

Enregistrer un commentaire