Answer to Question #267448 in Java | JSP | JSF for James

Question #267448

In or Out



by CodeChum Admin




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". Simple, right?




Now let's get this game started.




Input




A line containing an integer.




35



Output




A line containing a string.

1
Expert's answer
2021-11-17T06:28:09-0500
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner input = new Scanner(System.in);
	    System.out.println("Enter an interger: ");
	    int n=input.nextInt();
	    if(n%2==0){
		System.out.println("in");
	}
	else{
	    System.out.println("out");
	}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS