+ 2

Plz help what is the wrong

Import Java.util.Scanner Public class Ahmed{ Public static void main (String args []) { Scanner input = new Scanner(System.in) ; System.out.println ("Enter any value" ); Int x; Int x=input.nextInt(); Swtich grade { case A: if (x<=10) System.out.println("bad" ); } } }

25th Oct 2019, 11:35 PM
Ahmed taj
Ahmed taj - avatar
7 Answers
+ 6
here is the corrected code as well https://code.sololearn.com/cXH9aV8B48dQ/?ref=app
26th Oct 2019, 12:11 AM
꧁àŒș Jenspi àŒ»ê§‚
꧁àŒș Jenspi àŒ»ê§‚ - avatar
+ 6
you’re welcome! the best way to learn is to make mistakes
26th Oct 2019, 12:24 AM
꧁àŒș Jenspi àŒ»ê§‚
꧁àŒș Jenspi àŒ»ê§‚ - avatar
+ 5
lets work from top to bottom: 1. import and java need to be lowercase. you need a semicolon after importing, and “import” needs to be on the same line of what you are importing. 2. public should be lowercase in both class and main method declarations 3. int needs to be lowercase. there is a difference between int and Integer. 4. the variable x is already declared, so you would do x= to initialize it, or just do int x = since you already know what the value is. 5. switch is spelled wrong, and should not be capitalized. its arguments should be in parenthesis: switch(variable){...}. you are also giving it the variable “grade” which doesnt exist in your code. i think you are looking to pass your variable x through. Cases should be given a literal (2, “2”), which A is neither. youll need to give it a specific value to look for, like a number or string. You need to add “break;” at the end of each case block. hopefully i explained it well enough :)
26th Oct 2019, 12:06 AM
꧁àŒș Jenspi àŒ»ê§‚
꧁àŒș Jenspi àŒ»ê§‚ - avatar
+ 2
Hello Ahmed For the Future please use the plus button to import your code in your post like jenny do this above. It's more easyer to understand what's your problem is. If you use first the sololearn code editor you find by your self many Errors. Because the compiler give you nice error messages if your code not correct. I use on my Laptop Eclipse as IDE. It's a nice tool to write Java code. And many more. Look at the webside of eclipse https://www.eclipse.org/ Regards kiuziu
26th Oct 2019, 12:22 PM
Kiuziu 💘 Berlin
Kiuziu 💘 Berlin - avatar
+ 1
Thnx you very much
26th Oct 2019, 12:09 AM
Ahmed taj
Ahmed taj - avatar
+ 1
Thnx for correct the code
26th Oct 2019, 12:20 AM
Ahmed taj
Ahmed taj - avatar
0
You have to delete the first int x;
27th Oct 2019, 11:50 AM
Manuel Gonzalez Leal
Manuel Gonzalez Leal - avatar