Level 11 ...Help (Revise)


#1

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

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

int subwayTrain = ?;

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

	}

}

}

int subwayTrain = ?


#2

you have to print "This is a Brooklyn bound train!"

what should be the case to print that ?

if you set subwayTrain = 9 will it print that value?


#3

Sorry .
subwayTrain = ? ..
How do I set the value of subwayTrain equal to that?


#4

Did you understand how does switch case work?

consider if you set subwayTrain = 1 then what does it print and why so?


#5

subwayTrain = 5 ;
:roll_eyes:


#6

The value will be 5.


#7

Thank you!!
:heart_eyes:


#8

Thank you!!
:heart_eyes:


#9

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