dimanche 21 novembre 2021

Java - why is my else if and else not working. When i type the condition in else if, the statements from if shows, why is that? [closed]

this is the code im using, when i type no as an input it still shows the if statement. Is it maybe because i put a lot of conditions?

if(!sRes.equals("Yes") || !sRes.equals("yes") || !sRes.equals("YES") || !sRes.equals("yES") || !sRes.equals("yeS") || !sRes.equals("yEs") || !sRes.equals("YeS") || !sRes.equals("YEs"))
        {
            System.out.println("working");
            switch(pp){
                case 1:
                    System.out.println("i put a switch case in my if statement");
            }

} else if(!sRes.equals("No") || !sRes.equals("NO") || !sRes.equals("nO") || !sRes.equals("no")) {

            System.out.print("not working");

        } else {
            System.out.print("not working either");

        }

Aucun commentaire:

Enregistrer un commentaire