GeneralizationsB.java


#1

set the boolean variable tricky equal to the result (either true or false).
boolean tricky = ( 3 >= 3 && !(true || true) );


#2

Edit: I went back into the course and found what you were on.
Future reference, post the code & error you are having trouble with.

	// ( 3 >= 3 && !(true || true) )
	boolean tricky =

It wants you to use the precedence rules to help you evaluate the
Boolean expression in the single line comment above the tricky variable.

So first you would do (true || true) which is true. Due to the ( ! ) before it,
makes it opposite of what it really is so it would be false.

Next you have 3 >= 3 which is also true. So that leaves you with true && false.
Remember if you're using && and both sides are not true, it will be false.

Now that we have come to the conclusion that the statement is
false, you would set the boolean variable tricky to false.

        // ( 3 >= 3 && !(true || true) )
	boolean tricky = false;

#3

Thanks, great explanation. However, I am getting a Green Check-mark for Q1; but, the output shows an error:

Also, I am getting a Red Check-Mark for Q2

GeneralizationsB.java:6: error: not a statement
( 3 >= 3 && !(true || true) );
^
1 error


My Code

My updates are:

( 3 >= 3 && !(true || true) );
boolean tricky = false;

...And, I set subwayTrain = 9 to get the ELSE condition triggered


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

( 3 >= 3 && !(true || true) );
boolean tricky = false;

//
if (2015 < 2016)
{
System.out.println("Stuck in the past...");
}
else
{
System.out.println("Upgraded to the future!");
}

int subwayTrain = 9;

	switch (subwayTrain)
{
		case 1 : System.out.println("This is a South Ferry bound train!");
							break; 
		case 5 : System.out.println("This is a Brooklyn bound train!");
							break;
		case 7 : System.out.println("This is a Queens bound train!");
							break;
		default:
			System.out.println("I'm not sure where that train goes...");
	}

}

}


#4

A post was split to a new topic: Even if i change the boolean, the red X remains at Q2


#5

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

     boolean tricky2 = ( 3 >= 3 && !(true || true) );
boolean tricky	= false;



if (2015 >= 2016) {

		System.out.println("Stuck in the past...");

	} else {

		System.out.println("Upgraded to the future!");

	}


int subwayTrain = 5;

	switch (subwayTrain){

		case 1 : System.out.println("This is a South Ferry bound train!");
							break; 
		case 5 : System.out.println("This is a Brooklyn bound train!");
							break;
		case 7 : System.out.println("This is a Queens bound train!");
							break;
		default:
			System.out.println("I'm not sure where that train goes...");

	}

}

}


#6