Write a program to check whether a number is divisible by 5 and 11 or not


This Java program prompts the user to input a number and then checks whether the number is divisible by both 5 and 11 using the modulo operator and conditional statements.

The Scanner class is used to read input from the user, and the program prompts the user to enter a number and stores it in the variable num.

The program then uses an if statement with a logical && operator to check whether num is divisible by both 5 and 11. If num is divisible by both 5 and 11, it prints the message "This Number is Divisible by 5 and 11". If num is not divisible by both 5 and 11, it prints the message "This Number is Not Divisible by 5 and 11".

Source Code

import java.util.Scanner;
class Divisible_Number
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		System.out.print("Enter the Number  : ");
		int num = input.nextInt();
		if(num%5==0 && num%11==0)
			System.out.println("This Number is Divisible by 5 and 11");
		else
			System.out.println("This Number is Not Divisible by 5 and 11");
	}
}

Output

Enter the Number  : 55
This Number is Divisible by 5 and 11

Enter the Number  : 125
This Number is Not Divisible by 5 and 11

Example Programs