New in java dont know where the error is? | Sololearn: Learn to code for FREE!

+3

New in java dont know where the error is?

public class IfElse{ public static void main(String[] args) { //defining a variable int number=13; //Check if the number is divisible by 2 or not if(number%2==0){ System.out.println("even number"); }else{ System.out.println("odd number"); } } }

4/20/2021 1:57:24 AM

Naaz Hussain

10 Answers

New Answer

+2

Tell your excepted output because there is neither syntax nor logical errors

+5

[No Name] please use respect amongst other community members .. They overtime as you get to know them can help you with questions and answers as they arise in your growth.

+1

move the last } a little left then see

0

The code doesn't consists of any errors

0

Ok thanku 🙂

0

0

Maxamed Jamaal https://www.sololearn.com/discuss/1316935/?ref=app

0

Move bracket before else to line above. And I think your condition should be if(number%2=0) As you are checking the value. Idk, but otherwise correct. Now if you want to do extra then take Scanner class or any other util that will let you input values. If Scanner then do it like - int number = sc.nextInt(); Keep in mind sc is just a name and two statements should be entered before this. Check these out for more info - https://code.sololearn.com/cse9Ha0j82ZM/?ref=app https://code.sololearn.com/c1iL1xRzvUN5/?ref=app https://code.sololearn.com/cLYYmYO0dhX8/?ref=app https://code.sololearn.com/ceBz8V7JzLy3/?ref=app