Conditionals and Control Flow Exercise 11 Generalizations instruction 2


#1



https://www.codecademy.com/es/courses/learn-java/lessons/conditionals-control-flow/exercises/generalizations-conditionals?action=resume


Print the message in the else block.


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

	if ( 3 >= 3 && !(false || false) ){
	boolean tricky = false;		
			System.out.println(tricky);
  }else {
    boolean tricky = true;
    	System.out.println(tricky);
  }
	if(2020 < 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

So the above code seems to be the issue. You only need one if else statement for this lesson and you have it in the if(2020 < 2016) etc. part. There is a lot of extra code that you have put in here which may work when configured in the right way but is not necessary for what this lesson whats you to do. So, If you get rid of the if/else statement, put // back in front of the ( 3 >= 3 && !(false || false) ) just leave boolean tricky = false; you should be fine. Hopefully that makes sense and helps out. Here is the basic format of what I started my lesson with:

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

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

#3

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