I need the shipping cost to be determined by the various rates.
I've tried a hodgepodge of things for the last 5 hours. If I'm supposed to use .to_s .to_f, I've tried and done so incorrectly.
if (weight < 2)
rate = 0.10
elsif ((weight >= 2) or (weight < 10))
rate = 0.20
elsif ((weight >= 10) or (weight < 40))
rate = 0.30
elsif ((weight >= 40) or (weight < 70))
rate = 0.50
elsif ((weight >= 70) or (weight < 100))
rate = 0.75
else (weight >= 100)
rate = 0.90
end
rate = rate.to_i
ship_cost = weight * price * rate
ship_cost = ship_cost.to_i
The result is supposed to show a shipping cost after the rate is applied. I keep getting to the String to Integer error.
[]['foo'] Traceback (most recent call last): 6: from /Users/user/.rbenv/versions/2.6.3/bin/irb:23:in '<main>' 5: from /Users/user/.rbenv/versions/2.6.3/bin/irb:23:in 'load' 4: from /Users/user/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in '<top (required)>' 3: from (irb):6 2: from (irb):6:in 'rescue in irb_binding' 1: from (irb):6:in '[]' TypeError (no implicit conversion of String into Integer), that's a whole error, what you provided is not. It tells nothing to people reading your question.*': no implicit conversion of String into Integer (TypeError) from /Users/gemarh/RubymineProjects/Ch4Asg.rb/Ch4Asg.rb:35:in<main>'