+ 1

Please help me solve this problem in the Java Beginner's course: emotion-aware robot

In learning Switches, I am trying to get a result for the problem "Emotion-Aware Robot" It looks like everything is correct, but I can't get it to give me "completed" status. Here is the code: mport java.util.Scanner; class Demo{ 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" */ // add switch statement 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 Surprised!"); break; default: System.out.println("Unknown emotion"); } } }

9th Jul 2023, 10:33 AM
Stacey Prahl
9 Antworten
+ 5
"Sad" and "sad" are not the same. Pay attention how the expected output is written in the task description, regarding uppercase and lowercase letters.
9th Jul 2023, 10:58 AM
Tibor Santa
Tibor Santa - avatar
+ 3
Save code in playground and share link here.. is your "import" has i Or not? Expected Output text has only Y capital, but your output has not matching.. It should be exactly same.. Otherwise, won't pass tests.
9th Jul 2023, 10:38 AM
Jayakrishna 🇮🇳
+ 2
When I put it in Code bits, it works fine, but when I put the code into the problem, It won't work. No error come up, and it doesn't say that I've completed the problem. The code can be found in my profile link: https://www.sololearn.com/Profile/29243802
9th Jul 2023, 10:51 AM
Stacey Prahl
+ 2
Your saved code has also option to share. Directly share code next time if needed.. It has no errors but as i already told, except first letter, display all in lower case letters.. as shown in description...
9th Jul 2023, 10:53 AM
Jayakrishna 🇮🇳
+ 2
For example: output expected is "You are sad!" But you are displaying "You are Sad!" // S in capital, but use small there.
9th Jul 2023, 10:57 AM
Jayakrishna 🇮🇳
+ 1
I Inside System.out.println() There is a typing error, here is the fix below import Java.util.Scanner; class Demo{ 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"); break; } } }
10th Jul 2023, 2:10 PM
Fiki ARDIANSYAH PRATAMA
+ 1
Nicee
10th Jul 2023, 2:23 PM
X Fire
X Fire - avatar
9th Jul 2023, 10:43 AM
Stacey Prahl
0
I don't understand this statement: Expected Output text has only Y capital, but your output has not matching.. It should be exactly same.. Otherwise, won't pass tests. Please explain.
9th Jul 2023, 10:55 AM
Stacey Prahl