A simple program to ask the user to give a number and then the program will check if the given number is odd or even using Scala programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.

Program Listing


// odd_even.scala
// Jake Rodriguez Pomperada,MAED-IT, MIT
// www.jakerpomperada.com  www.jakerpomperada.blogspot.com
// jakerpomperada@gmail.com
// Bacolod City, Negros Occidental Philippines

import java.util.Scanner;

object odd_even {
 def main(args: Array[String]):Unit={
  var scanner = new Scanner(System.in);

  // These functions test for even and odd numbers.
def isEven(number: Int) = number % 2 == 0
def isOdd(number: Int) = !isEven(number)

  print("\tOdd and Even Numbers in Scala");
  print("Give a number : ");
  var a = scanner.nextInt();

 if (isEven(a)) {
     println(s"The given number $a is even number.");
 } else {
     println(s"The given number $a is odd number.");

  println("END OF PROGRAM");