leap-year or not ?
# Fact: A year is a leap year if it is divisible by 4, unless it is divisible by 100. However, years divisible by 400 are leap years.
puts "Please enter the four digit Year "
year_string = gets.chomp
puts "You have entered , YEAR : " + year_string
# convert the inputted string into integer
year_integer=year_string.to_i
if year_integer<1000
puts "Invalid input!! Please reenter a 4 digit number"
exit
end
if( ( ( year_integer%4==0) and ( year_integer%100 != 0 ) ) or (year_integer%400 == 0 ) )
puts "Its a leap year."
else
puts "Its not a leap year"
end


4 Comments:
This comment has been removed by a blog administrator.
12:32 AM
Isn't blogging fun!! How are you finding the Ruby sessions?
12:36 AM
Exactly its a FUN but moreover a way to learn from "Sharing-Ideas" with each other. Session is really good 4 me n specially I am excited about your ASSIGNMENT which forces me to learn RUBY-concepts. I am much impressed with yout BOT technique.
Thanks to do so.
3:23 AM
Thanks for your generous comments about my approaches.
As part my job, I have to think outside the box constantly.
And my line manager keeps asking me for 3 possible solutions to every problem...so that has become kind of a second nature.
1:32 PM
Post a Comment
<< Home