Untitled
unknown
plain_text
a year ago
1.2 kB
8
Indexable
class Clothes:
def init (self, type,model_year, brand, price):
self.type = type
self.model_year = model_year
self.brand = brand
self.price = price
def count_price(self):
if self.type=="shirt":
discount=0.40
if self.type=="pants":
discount=0.30
if self.type=="shoes":
discount=0.50
else:
discount=0.0
return self.price*(1-discount)
def user_input():
type=input("enter the type (shirt,pants,shoes):")
model_year=input("enter the model year :")
brand=input("enter the brand :")
price=float(input("enter the price : "))
return Clothes(type,model_year,brand,price)
items = []
total_amount = 0
while True:
item = user_input()
discounted_price = item.count_price()
print(f"The price after discount for {item.type} is: {discounted_price: } EGP")
total_amount += discounted_price
more_items = input("Do you want to add more items? (yes/no): ").strip().lower()
if more_items != "yes":
break
print(f"The total amount to be paid for all items is: {total_amount: } EGP")
Editor is loading...
Leave a Comment