Write a java program to check whether the given number is divisible by 5

Write a java program to check whether the given number is divisible by 5. Enter any integer as an input for this Java program to check if a given number is divisible by 5. To check the divisibility of a given integer by 5, we use the modulus operation. If the given integer divides by 5 with zero as a remainder, it is divisible by 5; otherwise, it is not divisible by 5. source code for the Java Program to Check Whether a Number is Divisible by 5

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int n;
Scanner s = new Scanner(System.in);
System.out.print("Enter any number:");
n = s.nextInt();
if(n % 5 == 0)
{
System.out.println(n+" is divisible by 5");
}
else
{
System.out.println(n+" is not divisible by 5");
}
}
}

 

Output:

Enter any number:45
45 is divisible by 5

Division number in java program

Division is one of the four basic mathematical operations, with addition, subtraction, and multiplication being the other three. Simply said, division is the process of dividing a large group into equal smaller units.

What are the uses of modulo operator in java programming

After division, the Modulo or Remainder Operator returns the remainder of the two numbers. If you’re given two numbers, say A and B, where A is the dividend and B is the divisor, is there a residue of A and B’s division? The modulo operator is an arithmetic operator indicated by the letter percent.