Computer Science, asked by ac1485, 1 year ago

write a program in java to find out if the number is divisible by 2 or not???

Answers

Answered by shinyyy
1
Heya!!! here is ur answer....


public class divisible
{
public static void main(int n)
{
int d;
while (n!=0)
{
d= n% 10;
n = n/10;
{
if (d% 2==0)
System.out.println("the number is divisible by 2");
else
System.out.println ("not divisible by 2")
}
}
}
}

shinyyy: wlcm
shinyyy: pls mark as brainliest
ac1485: how
shinyyy: a notification will come as.... 'mark as brainliest' then u choose my answer
shinyyy: hii
Answered by AskewTronics
1

Java program for the above question is as follows:

Explanation:

import java.util.Scanner;

public class Divison

{

public static void main(String[] args)

{

    Scanner input = new Scanner(System.in);

    System.out.println("Enter a number to find it is divisble by 2 or not");

    int number = input.nextInt();

    if(number%2==0)

    System.out.println("The number is divisble by 2");

    else

    System.out.println("The number is not divisble by 2");

 

}

}

output :

  • If the user input as 4, then the output is divisible.
  • If the user input as 5, then the output is not divisible.

Code Explanation :

  • The above code is in java, which takes the input from the user.
  • Then check that input is a divisible by the 2 or not

Learn more :

  • Java  :  https://brainly.in/question/13792074
Similar questions