I need help with a problem (The emotion-aware robot) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I need help with a problem (The emotion-aware robot)

So I got 3 out of the 4 test case right!! Can some one tell me what I am missing in this code or if I did something wrong! I tested the code and I do not see any issue Your robot can recognize your emotions and can assign them a number to represent each of them: You are happy! You are sad! You are angry! You are surprised! The given code takes the emotion number as an user input. Task: Complete the code to output the corresponding message in the given format. If the input is an emotion that the program doesn’t know, it should output: "Unknown emotion". My Code: import java.util.Scanner; 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 suprised!"); break; default: System.out.println("Unknown emotion"); } } }

26th Jan 2023, 5:03 AM
Nicole Brooks
1 Answer
+ 1
Nicole Brooks Now its working just enter it..... Use emotion. ,instead of this emotion Use surprised ,instead of this suprised
26th Jan 2023, 5:31 AM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar