1. ## Logical Operators

How would I write an expression that evaluates to true if x is non-negative and y is negative when they have already been declared and assigned values?

2. ## Re: Logical Operators

What have you tried? Where are you stuck?

How do you test whether a value is negative or not?

3. ## Re: Logical Operators

Originally Posted by KevinWorkman
What have you tried? Where are you stuck?

How do you test whether a value is negative or not?
I have been working with Equality and Rational Operators for the past few days, and this is my first time being exposed to this type of material. I have no idea how to test whether the value is negative or not, and the I have tried this:

"!-x"
"!-y"

5. ## Re: Logical Operators

Originally Posted by KevinWorkman
When it is below zero, right?

6. ## Re: Logical Operators

Originally Posted by Everyman
When it is below zero, right?
Seems reasonable to me. Now do you see any comparative operators that test whether a value is less than another value?

7. ## Re: Logical Operators

Originally Posted by KevinWorkman
Seems reasonable to me. Now do you see any comparative operators that test whether a value is less than another value?

The tutorial I linked you to contains this page: Equality, Relational, and Conditional Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

These?:

"< less than"
"<= less than or equal to"

8. ## Re: Logical Operators

Originally Posted by Everyman
These?:

"< less than"
"<= less than or equal to"
What happened when you tried them?

9. ## Re: Logical Operators

Originally Posted by KevinWorkman
What happened when you tried them?
Good things. Good things happened, sir. Thank you for all of your help.

P.S.: This is the code that I used (x>=0 && y<0)

10. ## Re: Logical Operators

Awesome. Glad you got it sorted out.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•