+ 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 ." ); } } }
8 Answers
+ 2
Hi! your point after the word "emotion" and the previous line of code after the "surprised" exclamation point stand too far
+ 1
Last 2 cases text has extra space in output text as compared to expected one...!
-if you are trying this in code coach..!
+ 1
What error do you get?
What do you want to achieve?
What input have you given the program?
...
+ 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.
+ 1
Jayakrishna🇮🇳
Oh sorry! maybe I've seen this somewhere else.
+ 1
Jayakrishna🇮🇳 and Yaroslav Vernigora your answers are the only solution possible to the question
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
0
Nothing wrong with it. If you give a number it give the result.