# Java Program to Check whether Number is Divisible by 5 and 11

Write a Java Program to Check whether Number is Divisible by 5 and 11 using If Else statement and the Conditional Operator with example.

## Java Program to Check whether Number is Divisible by 5 and 11 Example 1

This Java program helps the user to enter any number. Next, it checks whether the given number is divisible by both 5 and 11 using If Else Statement.

```// Java Program to Check whether Number is Divisible by 5 and 11
import java.util.Scanner;

public class Divisibleby5and11 {

private static Scanner sc;
public static void main(String[] args)
{
int number;
sc = new Scanner(System.in);

System.out.print(" Please Enter any Number to Check whether it is Divisible by 5 and 11 : ");
number = sc.nextInt();

if((number % 5 == 0) && (number % 11 == 0))
{
System.out.println("\n Given number " + number + " is Divisible by 5 and 11");
}
else
{
System.out.println("\n Given number " + number + " is Not Divisible by 5 and 11");
}
}
}```

Let me try another value in this Java example.

`````` Please Enter any Number to Check whether it is Divisible by 5 and 11 : 205

Given number 205 is Not Divisible by 5 and 11``````

## Java Program to Verify Number is Divisible by 5 and 11 using Conditional Operator

This program uses the Ternary Operator to check whether the given number is divisible by both 5 and 11.

```// Java Program to Check whether Number is Divisible by 5 and 11
import java.util.Scanner;

public class Divisibleby5and11Ex2 {

private static Scanner sc;
public static void main(String[] args)
{
int number;
sc = new Scanner(System.in);

System.out.print(" Please Enter any Number to Check whether it is Divisible by 5 and 11 : ");
number = sc.nextInt();

String message = ((number % 5 == 0) && (number % 11 == 0))? " is Divisible by 5 and 11": " is Not Divisible by 5 and 11";
System.out.println("\n Given number " + number + message);
}
}```
`````` Please Enter any Number to Check whether it is Divisible by 5 and 11 : 55

Given number 55 is Divisible by 5 and 11``````