0
The switch statement of the pro questions?
Two things, first the 14.2 Practice Emotion detector the switch statement problem, renders my answers inaccurate even when I totally emulate the solution slide? I’m beginning to lose faith in the pro side of the program. Secondly, I’d asked a pro question before and an answer was posted by someone, but after I never found it, it’s not in the my question tab?
5 ответов
+ 1
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int emotion = scanner.nextInt();
switch (emotion) {
case 1:
System.out.println ("You are happy!");
break;
case 2:
System.out.println ("You are sad!");
break;
case 3:
System.out.println ("You are angry!");
break;
case 4:
System.out.println ("You are surprised!");
break;
default:
System.out.println ("Unknown emotion.");
}
}
}
This is the right code, make sure you double check yours for spelling errors
0
Attempts?
0
Please also be specific about the programming language. Many languages have switch statements.
0
Sorry, the language is Java im about two weeks into it and this app.
0
copy your code over to the codeplayground save it and share it here. So we can see where you may have made a mistake.