samedi 28 septembre 2019

at first if method works, after quite some weeks it does not work and show errors

Im very much a beginner on programming, i have been using netbeans11.1 for some quite a while now have the latest java sdk, the first time i make programs it just look like the same as taught at school (btw im practicing at home with my laptop) but after like 1 month and going to make another activity, the if method always show "incompatible type: int cannot be converted to boolean. im doing just the same syntax taught in school, so im confused why this is happening. and on making new project the java folder is not on the main list instead it has now java with maven, i dont know the difference but im really confused especially being a beginner` Scanner input = new Scanner(System.in);

    int in1, in2, out;

       System.out.print("Enter first number: ");
       in1 = input.nextInt();

       System.out.print("Enter second number: ");
       in2 = input.nextInt();

       out = in1 +in2;

       System.out.println("The anwer is:" + out);

       if (out % 2) {
           System.out.println("The answer is an even number");
       }
       else
           System.out.println("The answer is an odd number");

error in if method`

Aucun commentaire:

Enregistrer un commentaire