What am i doing wrong? 5Boolean Operations: Precedence


#1

My code:

public class Precedence {
public static void main(String[] args) {

	boolean riddle = !( 1 < 8 && (5 > 2 || 3 < 5));
	System.out.println(riddle);

	// ( !true || (false && true) )
	boolean puzzle = ( !true || (false && true) );
	System.out.println(puzzle);
	
	}
}
  1. Set the boolean variable puzzle equal to the Boolean result of the single line comment directly above it.

Error: Try again. The variable puzzle should equal either true or false.


#2

Instructions are sorta unclear, you're actually supposed to set puzzle equal to true or false based on the commented expression. ( !true || (false && true)) == false, so puzzle should equal false.


#3

The required use of boolean operators to be as mentioned below -

public class Precedence {
public static void main(String[] args) {

    boolean riddle = !( 1 < 8 && (5 > 2 || 3 < 5));
    System.out.println(riddle);

}

}


#4

i did this it showed this error. Did u use boolean operators no more than once each.


#5

leave space from relational operator to bracket or number


#6

my code print out false as instruction, and I use each boolean operator once but it still show error "Almost! Did you use each Boolean operator no more than one time?"