We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
However, what I don't understand is that in your solution you're leaving out -> (myInt%2==0 && (myInt >= 2 && myInt <= 5) -> and it still works. Thanks. @inanutshellus
Java If-Else
You are viewing a single comment's thread. Return to all comments →
Hi,
Whilst your solution works, I am trying to figure out how you came to this solution? What was your way of thinking?
My solution is the following:
if (myInt%2==0 && (myInt >= 2 && myInt <= 5)){ return "Not Weird"; }else if (myInt%2==0 && (myInt >= 6 && myInt <= 20)){ return "Weird"; }else if (myInt%2==0 && myInt >20) { return "Not Weird"; }else{ return "Weird"; }
However, what I don't understand is that in your solution you're leaving out -> (myInt%2==0 && (myInt >= 2 && myInt <= 5) -> and it still works. Thanks. @inanutshellus