28 lines
619 B
Python
28 lines
619 B
Python
rate1 = 10.0
|
|
threshold1 = 100
|
|
discount1 = 0.1
|
|
|
|
rate2 = 11.0
|
|
threshold2 = 200
|
|
discount2 = 0.3
|
|
|
|
def compute_cost_discount(quantity, rate, threshold, discount):
|
|
cost = rate * quantity
|
|
if quantity>=threshold:
|
|
cost = cost*(1.0-discount)
|
|
return cost
|
|
|
|
|
|
customer = input('Enter customer name: ')
|
|
quantity = int(input('Enter order quantity: '))
|
|
|
|
cost1 = compute_cost_discount(quantity, rate1, threshold1, discount1)
|
|
cost2 = compute_cost_discount(quantity, rate2, threshold2, discount2)
|
|
|
|
lowest_cost = cost1
|
|
|
|
if cost2<lowest_cost:
|
|
lowest_cost = cost2
|
|
|
|
print('Lowest Cost for', customer, ':', lowest_cost)
|