From: Jared Miller Date: 2010-10-02T08:33:47+09:00 Subject: Re: New to Ruby, Looking for Help With Basic Program --001636c5b20aae3a5d0491969e33 Content-Type: text/plain; charset=ISO-8859-1 Mica, are you going through the book *Learn to Program* by Chris Pine? That's what I'm going through as well, and he has you do that exact same program. puts 'What is the starting year?' starting = gets.chomp.to_i > puts 'What is the ending year?' ending = gets.chomp.to_i > puts 'Here is your list of leap years!' > year = starting > while year <= ending if year%4 == 0 if year%100 != 0 || year%400 == 0 puts year end end year = year + 1 end puts 'Done!' --- Jared Miller On Fri, Oct 1, 2010 at 4:17 PM, Jeremy Bopp wrote: > On 10/01/2010 03:00 PM, Mica Koizumi wrote: > > Thank you Jeremy! I changed: > > > > if year1.to_i % 4 == 0 > > leapyear = year1.to_i + 4 > > puts leapyear > > > > to: > > > > if year1.to_i % 4 == 0 > > year1 = year1.to_i + 4 > > puts year1 > > > > > > and that helped a great deal. I see now that I was not evaluating the > > incrementation. > > > > You guys have been a great help! > > I have another suggestion to help simplify your code a bit. Replace > these lines: > > year1 = gets.chomp > year2 = gets.chomp > > With: > > year1 = gets.chomp.to_i > year2 = gets.chomp.to_i > > Now you can drop all the .to_i business elsewhere in this code since > year1 and year2 will be integers from the beginning. > > -Jeremy > > --001636c5b20aae3a5d0491969e33--