Generalisation and conditionals (GeneralizationsB.)


#1

IM CLUUUUUUUUUUUUUUUULESS PLZ HELP

RULES
1.
Use the precedence rules to help you evaluate the Boolean expression in the single line comment above the tricky variable.

Then, set the boolean variable tricky equal to the result (either true or false).

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

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

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...");

	}

}

}


#2

First step tells you to evaluate step by step given Boolean expression 3 >= 3 && !(true || true), next you assign variable tricky to the right result either true or false.


#3

can u plz write the line im getting wrong?


#4

This is the line from your posted code that you are working on for this step:

boolean tricky ()

The exercise wants you to assign a value to tricky. To assign value you would start out like this, using the assignment operator =:

boolean tricky =

Do you see the word boolean there? That is the type of value that you are expected to use. There are only two boolean values that you can choose: true or false.

How do you know which one to use? You can go at that several ways:

You can evaluate the expression that the exercise is asking you to evaluate or you could guess.

There are a couple ways to evaluate the expression. You can work it out yourself or you can ask the computer to do it for you.

Working it out for yourself:

3 >= 3 && !(true || true)
3 >= 3 && !(true)
3 >= 3 && false
true && false
false

Asking Java to do it for you:

System.out.println( 3 >= 3 && !(true || true) )

Either way, you now have the result and can assign it to your variable called tricky by using the assignment operator.


#5

A post was split to a new topic: I have tried this multiple ways, even though the program runs, lesson is not allowing me to move on


#6