+ 1
How to receive input from user for switch case?
can't receive input from user to pass to the switch case and show other errors as well. https://code.sololearn.com/ctw45s71Mg3Q/?ref=app
2 Respuestas
+ 4
https://code.sololearn.com/c49T2k272N7O/#java
Your switch is outside of the main method for some reason. So either put it into the main or put it into its own method. As well, you have a lot of typos (syntax errors). I've posted up code to the playground for you, that should get you back on track.
Good luck.
public static void main(String[] args)
{
String name = "papa panther";
int x = 3, y = 2;
int sum = x + y;
++sum;
String lo = "black", ho = "big";
Scanner pap = new Scanner(System.in);
System.out.println("enter a number :");
int jam = pap.nextInt();
if(jam < 0) {
System.out.println("too short and negative:");
}
else if(jam > 0 && jam < 10) {
System.out.println("big enough");
}
else if(jam > 10) {
System.out.println("too big");
}
System.out.print(name + lo + ho);
System.out.println(sum);
int pop = pap.nextInt();
switch(pop) {
case 1:
System.out.println("nice day");
break;
case 2:
System.out.println("work day");
break;
default:
System.out.println("wrong choice");
break;
}
}
+ 2
Switch is outside of Main. move it into main and fix println