From: Mike Stok Date: 2013-06-24T06:53:20+09:00 Subject: Re: How do I input a variable floating point number into Ruby Programs On 2013-06-23, at 5:28 PM, "Michael P F." wrote: > I get the following error message in Ubuntu Terminal > > michael@michael-desktop:~/Desktop$ ruby /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot > load such file -- highline/import (LoadError) > from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' > from -:4:in `
' > michael@michael-desktop:~/Desktop$ ^C > michael@michael-desktop:~/Desktop$ > > Thanks for the effort, anyway > > Mike Finerty > > -- > Posted via http://www.ruby-forum.com/. That means you don't have the highline gem installed, it is a little more verbose if you don't use that, we have to check for the input being exhausted and for input which can't be turned into a Float so maybe: #!/usr/bin/env ruby CONST = 28977682.9 catch (:done) do loop do print "Enter number: " throw :done unless response = gets if num = Float(response) rescue nil puts CONST / num else puts "enter a number please." end end end puts "Bye!" __END__ Hope this helps, Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.