Your robot can recognize your emotions marked with number that represents each of them: 1 - You are happy! 2 - You are sad! 3 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Your robot can recognize your emotions marked with number that represents each of them: 1 - You are happy! 2 - You are sad! 3

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." */ 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."); } // your code goes here } } Test case : 5 got failed why???

6th Dec 2021, 4:13 AM
riddhi malviya
riddhi malviya - avatar
1 Answer
+ 3
👉! 4 - "You are surprised!" case 4: System.out.println("You are surprised");
6th Dec 2021, 4:35 AM
Solo
Solo - avatar