mardi 19 janvier 2021

If statement in Java not giving proper output [duplicate]

Hey all I am new to Java and so far my greatest enemy has been if statements. The program I am working on is a simple decision maker that is supposed to tell the user if they should get either a laptop or pc. My current if statement is only displaying the laptop option and not the PC, even when I set every single value correctly (or so I thought correctly). The current if statement is...

if(travel>=3){
    setProperty("textOutput", "text", "Laptop");
} else if(space=="Very Few Space"){
    setProperty("textOutput", "text", "Laptop");
} else if((money<=1000)&&(use=="Home")){
      setProperty("textOutput", "text", "Laptop");
} else{
      setProperty("textOutput", "text", "PC");
}

Anyone notice the issue I'm not seeing?

Aucun commentaire:

Enregistrer un commentaire