Computer Science, asked by ruchi396, 1 year ago

write a Java program to check whether the entered number is divisible by 5 or not

Answers

Answered by Tarun304
8
public class Divisible
{
public void main ( int n)
{
if(n%5==0)
System. out.print(n+ "is divisible by 5");
else
System.out.print(n+ "is not divisible by 5");
}
}

ruchi396: thank you
Incredible29: u r welcm
Answered by Incredible29
6
Heya user
Here is your answer !!

____________

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

____________

Hope it helps !!

ruchi396: thank you
Similar questions