In this article, we will show you, How to write a Java Program to Check whether Number is Divisible by 5 and 11 with example using If Else Statement, and the Conditional Operator.

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

This program helps user to enter any number, and check 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"); } } }

**OUTPUT**

Let me try another value

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

This program will use 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); } }

**OUTPUT**

Thank You for Visiting Our Blog