Rewrite each condition below in valid Java syntax (give a boolean expression): a. x > y > z b. x and y are both less than 0 c. neither x nor y is less than 0 d. x is equal to y but not equal to z

Respuesta :

Answer:

The boolean expression is the expression which can be evaluated to true or false. This true/false is called boolean value. An if statement is used to check a condition which often contains the boolean expression which can either evaluate to true or false.

a. x > y > z

This line means that the value of variable x is greater than the value of variable y and the value of variable y is greater than the value of variable z.

This means:

                            x is greater than y AND y is greater than z

                                                     x > y AND y > z

in JAVA                                         x > y && y > z

using if statement                        if(x > y && y > z)

it can also be written as:       if (x > y && x > z && y >z)

b. x and y are both less than 0

This statement means that the value of variable x and the value of variable y are less than 0

This means:                                   (x AND y) = 0

in JAVA                                          (x&&y)==0

using if statement:                 if ((num&&hum)==0)

This can also be written as       x < 0 AND y < 0

 In JAVA                                         x  < 0 && y < 0

using if statement                       if (x < 0 && y < 0)

c. neither x nor y is less than 0

This statement means that neither the value of x variable nor the value of y variable is less than 0. This clearly means that the value of x and value of y both values are greater than or equal to 0.

this means:

                                                 x > = 0 AND y > = 0  

In JAVA                                      x > = 0 && y > = 0

Using if statement                     if(x > = 0 && y > = 0)

It can also be written as                    (x && y > = 0)

                                                         if(x && y > = 0)

d. x is equal to y but not equal to z

This statement means that the value of x is equal to the value of y but the value of x is not equal to the value of z.

This means

                                                         x = y but x ≠ z

                                                         x=y AND x≠z

In JAVA                                              x==y && x!=z

Using if statement                           if (x == y && x != z)

it can also be written as                    if (x == y && y != z)

If x is equal to y so this means that the value of x and y will be the same and both the values will not be equal to the value of z.

RELAXING NOICE
Relax