JAVA PROGRAM ENTER ANY 50 NUMBER CHECK DIVISIBLE BY 5 OR 10
Answers
Answered by
1
hi mate,
- Answer:
- Java Program to Check Whether Given Number is Divisible by 5
- This is a Java Program to Check Whether Given Number is Divisible by 5.
- Enter any integer as an input. We use modulus operation to check the divisiblity of given integer by 5. If the given integer gives zero as remainder when divided by 5 then it is divisible by 5 or else its not divisible by 5.
- Here is the source code of the Java Program to Check Whether Given Number is Divisible by 5. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;
public class Check_Divisiblity
{
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:
$ javac Check_Divisiblity.java
$ java Check_Divisiblity
Enter any number:45
45 is divisible by 5
Enter any number:16
16 is not divisible by 5
i hope it helps you.
Similar questions