brewersfan1976

rounders.rb

Aug 31st, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.35 KB | None | 0 0
  1. def rounders(value)
  2.     string = value.to_s
  3.     string_length = string.length
  4.     x = 1
  5.    
  6.     if string[string_length - 1] <= '4' then
  7.        value = value.round -(string_length - 1)
  8.     else
  9.         while (x <= string_length - 1)
  10.               value = value.round(-x)
  11.                x = x + 1
  12.         end
  13.     end
  14.    
  15.     return value
  16. end
Advertisement
Add Comment
Please, Sign In to add comment