CS coding
CS coding
store_items = {
"Apple": 0.5,
"Banana": 0.3,
"Orange": 0.7,
"Milk": 1.5,
"Bread": 2.0,
"Eggs": 3.0
shopping_cart = {}
while True:
# Display menu
print("5. Checkout")
print("6. Exit")
if choice == "1":
7
# View available items
print("\nAvailable Items:")
if item in store_items:
if item in shopping_cart:
shopping_cart[item] += quantity
else:
shopping_cart[item] = quantity
else:
if item in shopping_cart:
shopping_cart.pop(item)
8
else:
shopping_cart[item] -= quantity
else:
# View cart
if not shopping_cart:
else:
total = 0
total += price
print(f"\nTotal: ${total:.2f}")
# Checkout
if not shopping_cart:
else:
9
total = 0
total += price
print(f"\nTotal: ${total:.2f}")
if confirm == "yes":
shopping_cart.clear()
else:
print("\nCheckout canceled.")
break
else:
10