距离换算器

2015-05-29 0 255
距离换算器
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}"

遇见资源网 ruby 距离换算器 http://www.ox520.com/16358.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务