Skip to content

Commit 295737f

Browse files
committed
Check Leap Year
1 parent cabb853 commit 295737f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def check_leap_year (year)
2+
year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)
3+
end
4+
5+
6+
def check_year_number (n)
7+
if n < 1
8+
print("Oh, invalid year!\n")
9+
exit
10+
end
11+
end
12+
13+
# Main
14+
print("Enter Year: ")
15+
year = gets.chomp.to_i
16+
check_year_number(year)
17+
18+
puts check_leap_year(year)
19+
###

0 commit comments

Comments
 (0)