The problem was that when I put a false temperature or a false wind speed. It display correctly. However, when I put both false value, it only display "Invalid wind speed." How can I make it display both else if and else condition?
I mean yeah, precedence, but your temperature can't be less than 58 AND greater than 41 simultaneously, and if it is... well, you've goofed real bad.
EDIT: And yes, I did forget the parentheses (my bad), and yes, you definitely do need them around the temp checks, because in this case it produces the worst possible type of error: sometimes it correctly reports, and sometimes it doesn't. That was a big mistake on my part, but I'm leaving it because it happened and shouldn't be ignored.
Ok, Yawzheek's suggestion was ok for the most part until I only enter the invalid value of temperature and it even display "Invalid windspeed and temperature" while I wanted it only to display "Invalid temperature". Also, the code of Abstraction was way too advance for my class now. Any other simple way only using Else-If and operator?
the code of Abstraction was way too advance for my class now.
If you've covered bool data types, there shouldn't be anything advanced about what I posted.
Line 8: Declares two bool variables. One to indicate the temperature is ok, and one to indicate the windspeed is ok.
The only thing even slightly tricky is lines 13 and 14. These are simply boolean expressions that set the corresponding boolean variable. The first one is equivalent to: