update,
This commit is contained in:
27
max015/T04/test_2_5.py
Normal file
27
max015/T04/test_2_5.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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)
|
Reference in New Issue
Block a user