Write a program using hashes to check and determine which of the following years
1991,1992,1993,1994,1995,1996,1998,1999,2000,2001,2002,2003,2004,2008,2012,
2016,2020 and 2024 are leap years and not a leap years and display the results
on the screen.
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 in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
Program Listing
# leap_year.rb
# Author : Jake Rodriguez Pomperada,BSCS,MAED-IT
# Date : July 18, 2019 Thursday 4:58 AM
# Address : Bacolod City, Negros Occidental
# Tools : Eclipse IDE and Ruby Version 2.6.3
# Location : Bacolod City, Negros Occidental
# Website : http://www.jakerpomperada.com
# Emails : jakerpomperada@gmail.com and jakerpomperada@yahoo.com
print "\n"
print "\t===== Leap Year Checker Using Hashes ====="
print "\n\n"
year_list = {
1 =>1991,2=>1992,3=>1993,4=>1994,
5 => 1995,6 =>1996,7=>1998,8 =>1999,
9 =>2000,10 =>2001,11=>2002,12 =>2003,
13 => 2004,14 =>2008,15=>2012,16=>20016,
17=>2020,18=>2024
}
print("\tList of Leap Years")
print("\n\n")
print("\t")
year_list.each do |key, value|
if ((value % 4 == 0) && (value % 100 != 0) || (value % 400 == 0))
print " #{value} "
end
end
print("\n\n")
print("\tList of Not a Leap Years")
print("\n\n")
print("\t")
year_list.each do |key, value|
if ((value % 4 != 0))
print " #{value} "
end
end
print "\n\n";
print "\tEnd of Program"
No comments:
Post a Comment