Java program to print "In" for even number & "Out" for rest | AskTheCode

Java program to check even number | Java Programming Solution | AskTheCode

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

}

}


19 views0 comments

Recent Posts

See All

Calculate BMI in Java | AskTheCode

Write a Java program that reads values for weight in kilograms and height in centimeters and prints out the BMI... interpretation of it...

"Believe you can and you're halfway there"