用户登录
用户注册

分享至

距离换算器

  • 作者: 人生如只是初见
  • 来源: 51数据库
  • 2022-08-12
print "Enter an amount: "
amount = gets.to_f
print "Convert it from what(inches, feet, miles, millimeters, centimeters, meters, or kilometers): "
from = gets.chomp
print "To what(same options): "
to = gets.chomp
# Set the values in relation to millimeters
values ={
'millimeters' => 1,
'centimeters' => 10,
'inches' => 25.7,
'feet' => 308.4,
'meters' => 1000,
'kilometers' => 1000000,
'miles' => 1628352
}

total = (values[from] / values[to].to_f) * amount

puts "That would be #{total} #{to}"
软件
前端设计
程序设计
Java相关