Write a ruby method calculate_discount
which takes three parameters: price
, discount_type
, and discount_value
. It first checks if the discount_type
is either "percent"
or "fixed"
. If it's neither, the method returns "Invalid discount type"
. For a "percent"
discount, it calculates the discount amount as a percentage of the price and subtracts it. For a "fixed"
discount, it directly subtracts the discount_value from the price. The method then ensures that the final price does not go below zero by comparing it to zero and returning the maximum value. The final price after applying the discount is returned.