COMPUTER_SCIENCE_PROJECT[1]
COMPUTER_SCIENCE_PROJECT[1]
PROJECT
TOPIC : SHOE SHOP CUSTOMER MANAGEMENT
CERTIFICATE
def add_customer():
customer_id = input("Enter Customer ID: ")
name = input("Enter Name: ")
phone = input("Enter Phone: ")
email = input("Enter Email: ")
address = input("Enter Address: ")
price = float(input("Enter Price (total spent or credit limit): "))
customer = {
"customer_id": customer_id,
"name": name,
"phone": phone,
"email": email,
"address": address,
"price": price
}
customers.append(customer)
print(f"Customer '{name}' added successfully.")
def view_customers():
if not customers:
print("No customers available.")
else:
for customer in customers:
display_customer(customer)
def search_customer(customer_id):
for customer in customers:
if customer["customer_id"] == customer_id:
return customer
return None
def update_customer():
customer_id = input("Enter Customer ID to update: ")
customer = search_customer(customer_id)
if customer:
print("Enter new details (leave blank to keep current information):")
name = input("New Name: ") or customer["name"]
phone = input("New Phone: ") or customer["phone"]
email = input("New Email: ") or customer["email"]
address = input("New Address: ") or customer["address"]
price = input("New Price (leave blank to keep current): ") or customer["price"]
price = float(price) # Convert to float if updated
def delete_customer():
customer_id = input("Enter Customer ID to delete: ")
customer = search_customer(customer_id)
if customer:
customers.remove(customer)
print(f"Customer '{customer_id}' deleted successfully.")
else:
print("Customer not found.")
def display_customer(customer):
print(f"ID: {customer['customer_id']}, Name: {customer['name']}, Phone:
{customer['phone']}, Email: {customer['email']}, Address: {customer['address']}, Price:
{customer['price']}")
def save_records(filename="customers.txt"):
with open(filename, 'w') as file:
for customer in customers:
line = f"{customer['customer_id']},{customer['name']},{customer['phone']},
{customer['email']},{customer['address']},{customer['price']}\n"
file.write(line)
print("Customer records saved to file.")
def load_records(filename="customers.txt"):
try:
with open(filename, 'r') as file:
for line in file:
customer_id, name, phone, email, address, price = line.strip().split(',')
customer = {
"customer_id": customer_id,
"name": name,
"phone": phone,
"email": email,
"address": address,
"price": float(price) # Convert price back to float
}
customers.append(customer)
print("Customer records loaded from file.")
except FileNotFoundError:
print("No previous records found. Starting fresh.")
def generate_receipt():
customer_id = input("Enter Customer ID for receipt: ")
customer = search_customer(customer_id)
if customer:
items = []
total_amount = 0
print("Enter item details (type 'done' as item name to finish):")
while True:
item_name = input("Item Name: ")
if item_name.lower() == 'done':
break
quantity = int(input("Quantity: "))
price = float(input("Price per item: "))
amount = quantity * price
items.append((item_name, quantity, price, amount))
total_amount += amount
# Main Program
def main():
load_records()
while True:
print("\n--- Shoe Shop Customer Management ---")
print("1. Add Customer")
print("2. View Customers")
print("3. Search Customer by ID")
print("4. Update Customer")
print("5. Delete Customer")
print("6. Save Records")
print("7. Exit")
print("8. Generate Receipt")
choice = input("Enter your choice: ")
if choice == '1':
add_customer()
else:
print("Invalid choice. Please try again.")
main()
OUTPUT
TEACHER’S SIGNATURE
PRINCIPAL’SIGNATURE