(a) whether the number is divisible by 2 and 5.
(b) Whether the number is divisible by 2 but not by 5.
(c)Whether the number is divisible by 5 but not by 2.
import java.util.*;
class program
{
public static void main (String args[])
{
int a;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
a=sc.nextInt();
if(a%2==0 && a%5==0)
System.out.println("No is divisible by both 2 & 5");
if(a%2==0 && a%5!=0)
System.out.println("No. is divisible by 2 but not by 5");
if(a%2!=0 && a%5==0)
System.out.println("No. is divisible by 5 but not by 2");
}
}
Output-
Enter the number
20
No is divisible by both 2 & 5
Enter the number
15
No. is divisible by 5 but not by 2
Enter the number
8
No. is divisible by 2 but not by 5