Any need for my emotion detector in java | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

Any need for my emotion detector in java

Hi I need help to complete the Emotion Detector Code practice in Java ... Test case # 5 failed every time and I can’t lookup coz it’s locked ! Thanks import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int emotion = scanner.nextInt(); /* 1 - "You are happy!" 2 - "You are sad!" 3 - "You are angry!" 4 - "You are surprised!" other - "Unknown emotion." */ // your code goes here 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 suprised!"); break; default: System.out.println("Unknown emotion."); } } }

24th Jan 2021, 2:25 PM
zer0x0
zer0x0 - avatar
9 Respuestas
+ 2
zer0x0 There is "surprised" not "suprised"
24th Jan 2021, 3:58 PM
A͢J
A͢J - avatar
+ 1
In my code case 5 is not working
8th Jun 2022, 6:28 PM
jyothi Reddy
jyothi Reddy - avatar
0
Code is working properly may be you missing something paste complete statement here .
24th Jan 2021, 3:44 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
thanks that was the answer 🙇‍♂️🙇‍♂️🙇‍♂️
24th Jan 2021, 4:52 PM
zer0x0
zer0x0 - avatar
0
Which one is test case 4? I keep getting everything good but test 4.. 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 hungry!"); break; case 4: System.out.println("You are surprised!"); break; default: System.out.println("Unknown emotion."); } } } Here is my code #help
4th Jun 2021, 5:42 PM
Gianfranco Amati
Gianfranco Amati - avatar
0
String emo = switch(emotion) { case 1 -> "You are happy!"; case 2 -> "You are sad!"; case 3 -> "You are angry!"; case 4 -> "You are surprised!"; default-> "Unknown emotion."; }; System.out.println(emo);
5th Sep 2021, 4:29 PM
Hao Nguyen Hung
Hao Nguyen Hung - avatar
0
Check your case 3 code seem correct check what will be your expected output in question
8th Jun 2022, 6:30 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
My case is correct but it's shows case 5 wrong
8th Jun 2022, 6:32 PM
jyothi Reddy
jyothi Reddy - avatar
0
Refer problem link here
8th Jun 2022, 6:33 PM
A S Raghuvanshi
A S Raghuvanshi - avatar