Help needed in exercise 11


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

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

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

if(2016 < 2015) {

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

	}

}

}

Replace this line with your code.

how does this code work?
this is what required
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).

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

Set the value of the int variable subwayTrain equal to the case that will print “This is a Brooklyn bound train!” to the console.

<do not remove the three backticks above>

#2

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