from tkinter import *
def raschet():
name = entry_name.get()
price = float(entry_price.get())
quantity = int(entry_quantity.get())
has_card = entry_card.get().strip().lower()
summa = price * quantity
if has_card == "да" and summa >= 1000:
discount_percent = 15
elif has_card == "да" and summa < 1000:
discount_percent = 5
elif has_card == "нет" and summa >= 3000:
discount_percent = 10
else:
discount_percent = 0
discount_amount = summa * discount_percent / 100
total_to_pay = summa - discount_amount
label_result.config(
text=f"Товар: {name}\nСумма: {summa} руб.\nСкидка: {discount_percent}%\nК оплате: {total_to_pay} руб.")
window = Tk()
window.title("Калькулятор скидок")
window.geometry("300x400")
Label(window, text="Название товара:").pack()
entry_name = Entry(window)
entry_name.pack()
Label(window, text="Цена:").pack()
entry_price = Entry(window)
entry_price.pack()
Label(window, text="Количество:").pack()
entry_quantity = Entry(window)
entry_quantity.pack()
Label(window, text="Карта (да/нет):").pack()
entry_card = Entry(window)
entry_card.pack()
btn = Button(window, text="Посчитать", command=raschet)
btn.pack(pady=10)
label_result = Label(window, text="", justify=LEFT)
label_result.pack(pady=10)
window.mainloop()