+ 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" ); } } }
7 Answers
+ 6
here is the corrected code as well
https://code.sololearn.com/cXH9aV8B48dQ/?ref=app
+ 6
youâre welcome! the best way to learn is to make mistakes
+ 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 :)
+ 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
+ 1
Thnx you very much
+ 1
Thnx for correct the code
0
You have to delete the first int x;