What’s wrong with my emotion detector code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What’s wrong with my emotion detector code?

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.print( "You are happy!" ); break; case 2: System.out.print( "You are sad!" ); break; case 3: System.out.print( "You are angry!" ); break; case 4: System.out.print( "You are surprised!" ); default: System.out.print( "Unknown emotion." ); } } }

8th Jun 2022, 6:00 PM
Aubrey Gibson
Aubrey Gibson - avatar
1 Answer
+ 5
Missing break for case 4.
8th Jun 2022, 6:14 PM
Jayakrishna 🇮🇳