Can't pass out Conditionals and control flow (2nd exercise 11th part) please help


#1

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

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

if (2015 < 2018);

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

	}

}

}

i am not sure what to do next please if someone could tell me
the option says :: 2.
Change the Boolean expression in the if statement so that your program will print out the code in the else block instead.


#2

true is boolean value not a string one

boolean value must be without " "

boolean tricky = "true"; //wrong

should be

boolean tricky = true;

and

( 3 >= 3 && !(true || true) //now think what should it be? true ? or false ?


#3

false i guess , correct me if i am wrong


#4

and i don't understand what this option means

Change the Boolean expression in the if statement so that your program will print out the code in the else block instead.


#5

yes it'll be false .

and i don't understand what this option means
Change the Boolean expression in the if statement so that your program will print out the code in the else block instead.

your code was

	if(2016 > 2015) {

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

		}else {

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

now if condition is true so it'll print if block(Stuck in the past...)
so you have to do if condition false so that your program will print out the code in the else block instead(Upgraded to the future!)


#6

i changed it to

if (2016 < 2015)
but i am still getting the error sir


#7

can you please give me a full screen shot?


#8


#9

in line 4
leave that as a comment what it was like

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

and
you removed opening bracket { after

if(2016<2015 ) { // <= here


#10

thank you so much just solved it .. just curiosity if i was going to make line 4 a comment why did the tutor (whoever wrote the code) put it there? and what does line 5 mean?


#11

i cant tell why the tutor put it there.may be he thinks it's better as he knows better than us. :slight_smile:

and line 5 means

you took a variable named tricky that is boolean type and add a boolean value false

hope you've understand :slight_smile:


#12

yeah man thank you so much :slight_smile:


#13

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.