Posts

Showing posts with the label even integer

mathajax

Java programming Integer Odd or Even and Year is Leap or not

The java code finds a given number whether it  is Odd or Even number. While executing the code, the user has to enter an input ,"positive integer" from the keyboard and  then following steps used to find the given input is Odd or Even.        Read an input , num Reminder = num % 2 check Reminder ==1 , print 'Odd Number' else, print 'Even Number' import java.util.Scanner; public class OddEven { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.println( "Find a given number is Odd or Evenn" ); System.out.println( "Enter a integer" ); int num=sc.nextInt(); sc.close(); if ( num%2 ==1 ) { System.out.println( num + " is Odd number" ); } else { System.out.println( num + " is Even number" ); } } } Output Find a given number is Odd or Even Enter a integer 5 5 is Odd number Output2 Find a given number is Odd or Ev...