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?

17th Jun 2022, 5:26 AM
Tania Pearson
5 Answers
+ 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
13th Jul 2022, 12:20 AM
Sarah
0
Attempts?
17th Jun 2022, 6:04 AM
AĶ¢J
AĶ¢J - avatar
0
Please also be specific about the programming language. Many languages have switch statements.
17th Jun 2022, 6:52 AM
Justice
Justice - avatar
0
Sorry, the language is Java im about two weeks into it and this app.
17th Jun 2022, 6:57 AM
Tania Pearson
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.
17th Jun 2022, 7:12 AM
Chris Coder
Chris Coder - avatar