Thanks, CodeSpawn. This place seemed too advanced for my question but I'll post my code here and see if anyone can help.
BTW, at the moment I wouldn't know where to post Ruby questions on your forum.
Here's my broken code anyway:
Code:
puts 'This program calculates leap years between 2 dates'
startyear = 0
endyear = 0
puts 'Enter start year:'
startyear = gets.chomp
if (startyear.to_i <= 0)
puts 'Your start year must be 1 AD or later!'
puts 'Re-enter start year:'
startyear = gets.chomp
end
puts 'Enter end year'
endyear = gets.chomp
if (endyear.to_i <= startyear.to_i)
puts 'Your end year must be later!'
puts 'Re-enter end year'
endyear = gets.chomp
end
puts 'So that\'s leap years between ' + startyear + ' and ' + endyear + '?'
puts 'OK, cool.'
countstart = startyear.to_i
countend = endyear.to_i
# check if its a leap year. Leap years are years divisible by four
# unless divisible by 100
# unless they are divisible by 400
while countstart <= countend
# check if its a leap year
if (countstart % 4 != 0) or ((countstart % 100 == 0) and (countstart % 400 != 0))
puts countstart.to_s + ' is not a leap year'
else
puts countstart
end
countstart = countstart += 1
end
puts 'that is all'
end