I'm trying to run this code:

puts 'LEAP YEAR CALCULATOR'
puts 'Enter the start year'
startyear = gets.chomp.to_i
puts ' '
puts 'Enter the end year'
endyear = gets.chomp.to_i
puts ' '
puts 'The leap years between the years you have entered are:'

while startyear <= endyear
  if startyear%4 == 0 and startyear%100 != 0 or startyear%400 == 0
#using modulus method %, which returns the remainder when the first number
is divided by the second
#using the == sign (is this equal), which is different from the = sign
(which is an assigning one to the other)
  puts startyear
  end
  startyear = startyear + 1
end

When I hit F5 this short program doesn't execute in the right pane. The DOS
prompt pops up but with no text, no way to enter text, and the curser sits
in the top left corner and flashes.

When I try this code:

bottles = 100

while bottles > 1
  bottles = bottles - 1
  line1 = bottles.to_s + ' bottles of beer on the wall,'
  line2 = bottles.to_s + ' bottles of beer,'
  line3 = 'if one of those bottles should happen to fall,'
  line4 = 'there\'d be ' + (bottles - 1).to_s + ' bottles of beer on the
wall'
  line5 = ' '
  puts line1
  puts line2
  puts line3
  puts line4
  puts line5
end

it works! The code executes, 99 bottles of beer on the wall is printed in
the right pane, from 100 bottles down to 0 bottles. This program has no
input required though, unlike the top one.

Yes I am new to this program, and Ruby, and programming.

Can anyone help?
-- 
View this message in context: 
http://www.nabble.com/F5-Go-not-working-for-Ruby-code-execution-tf2952508.html#a8257734
Sent from the SciTE mailing list archive at Nabble.com.

_______________________________________________
Scite-interest mailing list
Scite-interest@lyra.org
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to