In this tutorial, you are going to learn to write a java program to check whether a given number is divisible by 11 or not.
For example:
Take a number as input from the user.
Suppose a user has given
Input 1:
27
Output will be
Not divisible by 11
Input 2:
55
Output will be
Divisible by 11
Java program to check given number is divisible by 11
import java.util.*;
class Main
{
public static void main(String args[])
{
int num;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the input Number:");
num=sc.nextInt();
if(num%11==0){
System.out.println("Given number is divisible by 11");
}
else
{
System.out.println("Given number is not divisible by 11");
}
}
}
Output
Enter the input Number:
55
Given number is divisible by 11