{"id":1933,"date":"2017-05-02T06:29:34","date_gmt":"2017-05-02T06:29:34","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=1933"},"modified":"2024-09-04T15:42:51","modified_gmt":"2024-09-04T15:42:51","slug":"write-a-program-to-check-an-integer-is-even-or-odd","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/write-a-program-to-check-an-integer-is-even-or-odd\/","title":{"rendered":"Write a program to check an integer is Even or Odd"},"content":{"rendered":"<h2>Write a program to check an integer is Even or Odd<\/h2>\r\n<p>In this post, we will write a java program to check if the entered integer is Even or odd number. We will use Eclipse IDE in this example.<\/p>\r\n<h3>IPO Chart<\/h3>\r\n<p>IPO stands for <strong>Input- Process &#8211; Output<\/strong>. IPO is a handy tool to analyze the program input, process and outputs to the flowchart\/program. Beginners are recommended to create the IPO in a table format. Analyze the problem statement and think about the program inputs, processing steps and what the problem should display as output.\u00a0\u00a0<\/p>\r\n<p><strong>Input<\/strong> &#8211; User entered number.<\/p>\r\n<p><strong>Process<\/strong><\/p>\r\n<p>number%2 == 0 &#8211;&gt; EVEN<\/p>\r\n<p>Else &#8212;&gt; ODD<\/p>\r\n<p><strong>Output<\/strong><\/p>\r\n<p>Display whether the input number is odd or even number.\u00a0<\/p>\r\n<h3>Java Program<\/h3>\r\n<p>Launch Eclipse IDE. Create a new Java package and Java class.\u00a0<\/p>\r\n<p>Add the program code within the main method.\u00a0<\/p>\r\n<p>&nbsp;<\/p>\r\n<pre>package com.testingdocs.programs;\r\n\r\nimport java.util.Scanner;\r\n\r\n\/**************************************************\r\n * EvenOdd.java\r\n * @program   \t: Even or Odd check\r\n * @web        \t: www.TestingDocs.com\r\n * @version     : 1.0\r\n **************************************************\/\r\n\r\npublic class EvenOdd {\r\n\t\/\/ main method\r\n\tpublic static void main(String[] args) {\r\n\t\t\/\/ Take input from user\r\n\t\tScanner keyboard = new Scanner(System.in);\r\n\t\tSystem.out.print(\"Please enter the number :=\");\r\n\t\tint inputNumber = keyboard.nextInt();\r\n\t\t\/\/ Output \r\n\t\tif(inputNumber % 2 == 0 ) {\r\n\t\t\tSystem.out.println(\"The number \" + <br \/>inputNumber + \" is EVEN.\");\r\n\t\t}else {\r\n\t\t\tSystem.out.println(\"The number \" + <br \/>inputNumber + \" is ODD.\");\r\n\t\t} \/\/ end if\r\n\t} \/\/ end main\r\n} \/\/ end class\r\n\r\n\r\n<\/pre>\r\n<p>&nbsp;<\/p>\r\n<h3>Screenshot<\/h3>\r\n<p>Screenshot of the program in Eclipse IDE.<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21059\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Even-Odd-Java-Program.png\" alt=\"Even Odd Java Program\" width=\"1754\" height=\"1012\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Even-Odd-Java-Program.png 1754w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Even-Odd-Java-Program-300x173.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Even-Odd-Java-Program-1024x591.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Even-Odd-Java-Program-768x443.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Even-Odd-Java-Program-1536x886.png 1536w\" sizes=\"auto, (max-width: 1754px) 100vw, 1754px\" \/><\/p>\r\n<h3>Sample Output<\/h3>\r\n<p>Save the program code and execute the Java application. Execute some test cases to verify the program output.\u00a0<\/p>\r\n<p>To run the Java application, choose the menu option<\/p>\r\n<p><strong>Right click &gt;&gt; Run as &gt;&gt; Java application<\/strong><\/p>\r\n<p>The program will prompt to enter a number.\u00a0<\/p>\r\n<p><strong>Output<\/strong><\/p>\r\n<p>Please enter the number :=3<br \/>The number 3 is ODD.<\/p>\r\n<p>&#8212;<\/p>\r\n<p>Java Tutorial on this website: <strong><a href=\"https:\/\/www.testingdocs.com\/java-tutorial\/\">https:\/\/www.testingdocs.com\/java-tutorial\/<\/a><\/strong><\/p>\r\n<p>For more information on Java, visit the official website :<\/p>\r\n<p><strong><a href=\"https:\/\/www.oracle.com\/in\/java\/\" rel=\"noopener\">https:\/\/www.oracle.com\/in\/java\/<\/a><\/strong><\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Write a program to check an integer is Even or Odd In this post, we will write a java program to check if the entered integer is Even or odd number. We will use Eclipse IDE in this example. IPO Chart IPO stands for Input- Process &#8211; Output. IPO is a handy tool to analyze [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[24],"class_list":["post-1933","post","type-post","status-publish","format-standard","hentry","category-java-programs","tag-java-programs","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1933","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=1933"}],"version-history":[{"count":12,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1933\/revisions"}],"predecessor-version":[{"id":24196,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1933\/revisions\/24196"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=1933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=1933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=1933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}