Program:
package odd_or_even;
import java.util.Scanner;
public class jor_bijor {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int x;
System.out.println("Enter a number to check: ");
x=in.nextInt();
if(x % 2==0){
System.out.println("The number is even");
}
else{
System.out.println("The number is odd");
}
}
}
Output:
Enter a number to check:
15
The number is odd
package odd_or_even;
import java.util.Scanner;
public class jor_bijor {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int x;
System.out.println("Enter a number to check: ");
x=in.nextInt();
if(x % 2==0){
System.out.println("The number is even");
}
else{
System.out.println("The number is odd");
}
}
}
Output:
Enter a number to check:
15
The number is odd
No comments:
Post a Comment