mercredi 17 février 2021

How to check if char is unequal an input or a parameter? [duplicate]

        // Input for gender: 'm'
        if ( (gender == ' ') || (gender != 'm') || (gender != 'w') || (gender != 'j') ){
            
            System.out.println("Invalid gender input");
            return -1.0;
        
        } else{

Note: although I am having an unequal Check for m, the statement inside the if clause runs successfully, however it should jump into the else clause, because the input is 'm'

Aucun commentaire:

Enregistrer un commentaire