lundi 18 novembre 2019

Displays if a whole number (>0) is divisible by 2 and 3

I have tried to do this on java however the and symbols keep having an error. Below is the code that I used . int d = 18;

{
if ((d % 2) && (d% 3));
{
    System.out.println("True!");
}

{
    System.out.println("False!");
}

}

This is my code. I am not sure why its not working. Thanks The error message is "- The operator && is undefined for the argument type(s) int, int". #

Also when I add an else it says " Syntax error on token "else", delete this token"

Aucun commentaire:

Enregistrer un commentaire