stack = Array.new
while line = gets
  line.split(' ').each { |token|
    if "+-*/".include? token and token.length == 1
      if stack.length > 1
        second = stack.pop
        stack.push(eval("stack.pop #{token} second"))
      else
        puts "Stack underflow"
      end
    elsif token =~ /^[\d\.]*$/
      stack.push token.to_f
    else
      puts "Bad operator: #{token}"
    end
  }
  puts stack.last if stack.last
end

