Java - Is number an odd number

Description

Is number an odd number

Demo

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Day3 {
   //from   ww  w. j a v a 2s . c  o  m
   public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt(); 
      scan.close();
      String ans="";
          
      // if 'n' is NOT evenly divisible by 2 (i.e.: n is odd)
      if(n % 2 == 1){
         ans = "Weird";
      }
      else{
        ans = "even";
      }
      System.out.println(ans);
      scan.close();
   }
}

Related Topic