You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
box-o-sand/kiddofun/rounding.rb

10 lines
360 B

number = Integer(ARGV.fetch(0))
divisor = Float(ARGV.fetch(1, 10.0))
raise 'Invalid divisor' unless divisor % 10 == 0
puts "#{number} - number"
puts "#{(Float(number) / divisor).round(0)} - number divided by #{divisor}"
puts "#{(Float(number) / divisor).round(0) * Integer(divisor)} - " \
"number divided by #{divisor}, multiplied by #{Integer(divisor)}"