I need help for 2/10 SWITCH


#1

The program doesn't stop running. Why is that and how can I stop it?

This is the code:

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

	char penaltyKick = 'X';

	switch (penaltyKick) {

		case 'L': System.out.println("Messi shoots to the left and scores!");
							break; 

		case 'R': System.out.println("Messi shoots to the right and misses the goal!");
							break;

		case 'C': System.out.println("Messi shoots down the center, but the keeper blocks it!");
							break;

		default: System.out.println("Messi is in position...");
							break;
	}

}

}

After I run it, I get "Messi is in position..."


#2

Please give us the Link to the Excercise.

Maybe wrong Forum?

This looks like Java

public class Switch {
public static void main(String[] args)
System.out.println

In Javascript we use this

console.log();
document.write();

#3

https://www.codecademy.com/en/courses/learn-java/lessons/conditionals-control-flow/exercises/switch-statement?action=lesson_resume


#4

OK,

it worked now with the same conditions.

I don't know why.


#5

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