Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Odd or even program in java using a mod operator

import java.util.Scanner;public class Main{public static void main(String[] args){Scanner reader = new Scanner(System.in);System.out.print("Enter a number: ");int num = reader.nextInt();if(num % 2 == 0)System.out.println(num + " is even");elseSystem.out.println(num + " is odd");}}
Source by inlarn.com #
 
PREVIOUS NEXT
Tagged: #Odd #program #java #mod #operator
ADD COMMENT
Topic
Name
2+7 =