+ 1

Where's the mistake?

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

27th Sep 2022, 3:59 PM
Banan Hazaimeh
8 Answers
+ 2
Hi! your point after the word "emotion" and the previous line of code after the "surprised" exclamation point stand too far
27th Sep 2022, 4:12 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
Last 2 cases text has extra space in output text as compared to expected one...! -if you are trying this in code coach..!
27th Sep 2022, 4:09 PM
Jayakrishna 🇮🇳
+ 1
What error do you get? What do you want to achieve? What input have you given the program? ...
27th Sep 2022, 4:11 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
Snehil Pandey You can use any valid name for class.. Why not in sololearn? Anywhere it works.. In fact, you need to carefull about saving file to match with main class name in systems and in sololearn, you don't need to save any... So Class name has no effect in running file here... so no. we can use any name.
27th Sep 2022, 5:29 PM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳 Oh sorry! maybe I've seen this somewhere else.
27th Sep 2022, 5:42 PM
Random
Random - avatar
+ 1
Jayakrishna🇮🇳 and Yaroslav Vernigora your answers are the only solution possible to the question
27th Sep 2022, 6:03 PM
Random
Random - avatar
0
Banan Hazaimeh Sololearn doesn't support any other class name except 'Program'. So in order to compile your code which display output your code must have a class Program which contains all the main functioning of code Here is the code: https://code.sololearn.com/cAZvIXejCeBd/?ref=app
27th Sep 2022, 5:15 PM
Random
Random - avatar
0
Nothing wrong with it. If you give a number it give the result.
29th Sep 2022, 8:56 AM
Katari Vasu
Katari Vasu - avatar