top of page
Click here to go to the home page of AskTheCode.

Java program to check even number | AskTheCode

Team ATC

Updated: Mar 9, 2021

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);
	}
}

Recent Posts

See All

Comments


bottom of page