Created
December 29, 2011 06:33
-
-
Save odiepus/1532391 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Please enter a year to see if it is a leap year: " | |
year_input = gets.to_i | |
def leap_year? (input_year) | |
by_400 = input_year % 400 | |
by_4 = input_year % 4 | |
by_100 = input_year % 100 | |
if by_400 != 0 and by_100 == 0 and by_4 == 0 | |
return false | |
elsif by_4 != 0 | |
return false | |
else by_4 == 0 or by_400 == 0 | |
return true | |
end | |
end | |
boolean_answer = leap_year?(year_input) | |
def find_minutes_leap | |
leap = 366 | |
hour_leap = 366 / 24 | |
min_leap = hour_leap / 60 | |
end | |
def find_mins_not_leap | |
nonleap = 365 | |
hour_nonleap = 365 * 24 | |
min_nonleap = hour_nonleap * 60 | |
end | |
input_leap = find_minutes_leap | |
puts "This is a leap year. And there are %s minutes in that year." % input_leap if boolean_answer == true | |
puts "This is not a leap year." if boolean_answer == false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment