For example: 70 < temp <= 85
The result of " 70 < temp " is boolean, i.e. true or false.
What's the result of " boolean <= 85 " ?
It's obvious that the expression is wrong.
machoextreme - 04 Dec 2005 08:27 GMT
So your saying the reason why the expression doesn't work is that I'm
trying to evaluate a result, and not a varaible. So if I change the
boolean to boolean tennis =(70< temp) || (temp<= 85) would that be more
accurate?
ddk - 04 Dec 2005 08:37 GMT
you are right. but the statement should be :
boolean tennis =(70< temp) && (temp<= 85)
Roedy Green - 04 Dec 2005 09:19 GMT
>For example: 70 < temp <= 85
>The result of " 70 < temp " is boolean, i.e. true or false.
>What's the result of " boolean <= 85 " ?
>It's obvious that the expression is wrong.
In math you can say this, and in COBOL, but Java insists you spell out
such expressions longhand.
For some examples see http://mindprod.com/jgloss/boolean.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
>I was experimenting with an homework assignment(it called for
> if-then-else statements, which I finished thanks to some help from this
> forum), and was trying to see if I could accomplish it using boolean
> operators. However I get the following error operator <= cannot be
> applied to boolean, int. Any idea why?!?
> import java.util.*;
< cannot be applied to boolean.
< on int has a boolean return type. Boolean cannot be assigned to an int
variable.
-- Adam Maass
Thomas G. Marshall - 05 Dec 2005 04:14 GMT
Adam Maass said something like:
>> I was experimenting with an homework assignment(it called for
>> if-then-else statements, which I finished thanks to some help from this
[quoted text clipped - 7 lines]
> < on int has a boolean return type. Boolean cannot be assigned to an int
> variable.
I believe that he understands /that/ as such. What he was doing was
attempting a compound comparison similar to
(a < b < c)
Where the first a<b becomes the boolean.

Signature
Puzzle: You are given a deck of cards all face down
except for 10 cards mixed in which are face up.
If you are in a pitch black room, how do you divide
the deck into two piles (may be uneven) that each
contain the same number of face-up cards?
Answer (rot13): Sebz naljurer va gur qrpx, qrny bhg
gra pneqf naq syvc gurz bire.