Java program to check odd even | Java programming solutions | Ask The Code
Problem:
I'm quite into games now, so how about we play In or Out!
When a given number is even, the team scores so we shall print "In", but if it's not an even number, then we print "Out".
Input Format: A line containing an integer.
Input Sample:
35
Output Format: A line containing a string.
Output Sample:
Out
Code:
import java.util.Scanner;
public class Solution_InOrOut{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
String result = input % 2 == 0 ? "In" : "Out";
System.out.print(result);
}
}
Comments