Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def percent(bundled, not_bundled)
- # convert input to floats
- bundled = bundled.to_f
- not_bundled = not_bundled.to_f
- # verbose math
- bundled_not_bundled_sum = bundled + not_bundled
- # debugging
- puts bundled_not_bundled_sum
- # actual math
- percent_not_bundled = not_bundled / bundled_not_bundled_sum
- # limit to 2 points then get whole percent
- puts (percent_not_bundled.round(2) * 100).to_i
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement