WAP to accept a number from the user and check whether it is odd or even
Answers
Answered by
4
If you want to use Scanner class
import java.util.Scanner;
public class OddEven{
public static void main(String args[]){
Scanner scn = new Scanner(System.in);
System.out.print("Enter a number: ");
int x = scn.nextInt();
if(x℅2==0)
System.out.println(" Number is even);
else
System.out.println(" Number is odd);
}
}
If you don't want to use Scanner class
public class OddEven{
public static void main(int x){
if(x℅2==0)
System.out.println(" Number is even);
else
System.out.println(" Number is odd);
}
}
** Type the number at method call **
.
.
.
.
HOPE THIS HELPS YOU
.
.
.
.
PLEASE MARK AS BRAINLIEST AND FOLLOW ME TOO
Similar questions