$<.each_line do |l|
  stack = []
  l.split.each do |s|
    case s
    when /\d+/
      stack << s.to_f
    when ?+
      b = stack.pop
      a = stack.pop
      stack << a + b
    when ?-
      b = stack.pop
      a = stack.pop
      stack << a - b
    when ?*
      b = stack.pop
      a = stack.pop
      stack << a * b
    when ?/
      b = stack.pop
      a = stack.pop
      stack << a / b
    end
  end
  p stack.pop
end