write a program in Java to accept a number and check using simple if statement 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
Answers
Answered by
2
import Java. io. *;
class check
{
public static void mail(String args[])throws Exception
{
int n;
DataInputStream in= new DataInputStream(System.in);
System.out.println("Enter the number ");
n=Integer.parseInt(in.readLine());
if(n%2=0&&n%5==0)
System.out.println("Divisible by both 2 and. 5");
if(n%2==0&&n%2!=0)
System.out.println("Divisble by 2 not by 5");
if(n%2!=0&&n%5==0)
System.out.println("Divisible by 5 not by 2");
}
}
Hope it helps (。’▽’。)♡
class check
{
public static void mail(String args[])throws Exception
{
int n;
DataInputStream in= new DataInputStream(System.in);
System.out.println("Enter the number ");
n=Integer.parseInt(in.readLine());
if(n%2=0&&n%5==0)
System.out.println("Divisible by both 2 and. 5");
if(n%2==0&&n%2!=0)
System.out.println("Divisble by 2 not by 5");
if(n%2!=0&&n%5==0)
System.out.println("Divisible by 5 not by 2");
}
}
Hope it helps (。’▽’。)♡
sujal6232:
thank you
Similar questions