A simple Scala program to ask the user to give a year and then the program will check if the given year is a leap year or not 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

leap_year.scala

// leap_year.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 leap_year {
 
 def main(args: Array[String]):Unit={
 
  var scanner = new Scanner(System.in);

val isLeapYear = (year: Int) => (((year % 4) == 0) && !(
  ((year % 100) == 0) &&
  !((year % 400) == 0))
)
  println();
  print("\tLeap Year Checker in Scala");
  println("\n");
  
  print("Give a Year : ");
  var year = scanner.nextInt();
 
println("\n");

 if (isLeapYear(year)) {
     println(s"The given year $year is a Leap Year.");
 } else {
     println(s"The given year $year is Not a Leap Year.");
 }

  println();
  println("END OF PROGRAM");
  println();
 }
}

Leave a Reply

Your email address will not be published.