Ruby Ruby Basics Conditionals Boolean Operators

K .
K .
2,355 Points

Couldn't the first if statement in the price method be changed to just quantity > 100? not quantity >= 100??

Since the second if statement runs if the input is 100?

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 48,694 Points

If you are taking about this code:

def price(quantity)
    if quantity >= 100
         price_per_unit = 8
    end
    if quantity >=50 && quantity < 100
        price_per_unit = 9    
    end 
end

The following runs if quantity is less than 100 and greater than or equal to 50 but not equal to 100

 if quantity >=50 && quantity < 100

You can see this @7:55 in the video when a value of 100 is entered and the total is $800

K .
K .
2,355 Points

lol nvm, i got it. i dont know what I was thinking. thanks.