Question: I have tried to do this in java however the **&&** symbols keep on giving error.  

Below is the code that I used:

```java
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. #**

I have got it to work now. I have an else error . "The error says Syntax error on token "else", delete this token"

```java
public class CS1702_Lab3_4 {

    int d = 18;

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

```

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

Answer: 
Please learn about the modulus operator, and how to [check divisibility in java](https://stackoverflow.com/questions/8260690/how-to-check-if-number-is-divisible-by-a-certain-number).

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

```

Also, you had a rogue semi-colon at the end of your if statement.

EDIT: Fixed code

```
public class CS1702_Lab3_4 {

    public static void main(String[] args) { // Entry into our program
        int d = 18;

        if ((d % 2 == 0) && (d % 3 == 0)) {
            System.out.println("Divisible!");
        } else {
            System.out.println("Not divisible!");
        }
    }

}

```

I'd recommend looking at some basic Java tutorials, however the fixes I applied included:

* Contained your code inside of a method, specifically the main method, which is the entry point to a runnable Java application. Java is not a procedural language, code outside of variable, method, class, package and import declarations need to be contained inside of a method
* Fixed syntax on your if statement, removed rogue semi colon
1. `if ((d % 2) && (d% 3));` you have a semicolon `;` at the end,
remove it.
2. If `d == 18`, then `((d%2) && (d%3)) = (0 && 0) = 0` So in this  

case, What java sees is: `if(0){ // ... }`

If I remember correctly, this is valid in C/C++, but not in Java. That is why you get error.

Anyways, to fix the problem, you can do this:

```
if (((d % 2) == 0) && ((d % 3) == 0)){
     System.out.println("Divisible!");
} else {
    System.out.println("Not divisible!");
}

```