Answer to Question #3532 in Java | JSP | JSF for Y mukundareddy

Question #3532
Write a program to find the given number is an even or odd number using if else statements?
1
Expert's answer
2012-03-06T10:47:47-0500
import java.util.Scanner;




public class Main {




public static void main(String[] args) {




int n;

Scanner in = new Scanner(System.in);




System.out.print("Enter a number: ");

n = in.nextInt();

if(n % 2 == 0)

System.out.println(n + " is even");




else

System.out.println(n + " is odd");

}




}

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