CS PROJECT FILE (WITHOUT COVER)
CS PROJECT FILE (WITHOUT COVER)
INDEX
S.NO. TOPIC PAGE NO.
1 Certificate 3
2 Acknowledgement 4
4 Project Synopsis 6
5 Functions/Modules/Variables used 8
6 Code 9
7 Key Functions/Operations 21
8 Scripts 23
10 Bibliography 29
2|Page
CERTIFICATE
This is to certify that Sourav, a student of Class XII-B of Ryan
International School, Rohini, has successfully completed his
project titled “Food Ordering System with Loyalty Points and
Reporting Features” under my supervision. He has shown a
keen interest and demonstrated great sincerity in the
completion of this project.
I hereby certify that the project has been completed to my
expectations and in accordance with the guidelines issued by
CBSE, New Delhi.
PRINCIPAL
3|Page
ACKNOWLEDGEMENT
It is with great pleasure that I express my sincere gratitude to
Ms. Ritu Dawar, our teacher, for her valuable guidance and
support throughout the development of this project. Her
dedication to teaching and her constant encouragement have
been a source of inspiration not only for me but for all
students. I have greatly benefited from her classes and
guidance.
I am deeply indebted to Ms. Mamta Nanda, our Principal,
whose continuous encouragement and support have played a
pivotal role in the success of this project. Without her
inspiration and belief in my abilities, this project would not
have been possible. I extend my heartfelt thanks to her for her
unwavering support.
Lastly, I would like to express my sincere appreciation to all my
batch-mates for their friendship and for the unforgettable
moments we shared together. Their presence has made this
journey enjoyable and memorable.
4|Page
HARDWARE AND SOFTWARE REQUIREMENTS
Hardware Requirements:
• Processor: Intel Core i3 or equivalent
• RAM: 4 GB (8 GB recommended)
• Storage: 50 MB free disk space
• Display: 1024x768 resolution
• Input: Keyboard and Mouse
• OS: Windows 7 or higher, macOS, or Linux
Software Requirements:
• Programming Language: Python 3.6 or higher
• Libraries: datetime, csv, os, random
• IDE: Visual Studio Code, PyCharm, or any Python IDE
• Database: CSV files for data storage
5|Page
PROJECT SYNOPSIS
The Food Ordering System is a Python-based project that aims to streamline the
ordering process for a food service. The system allows customers to place
orders, apply discounts for loyal customers, and manage payments. It is
designed to be user-friendly, offering various features like order management,
generating sales reports, and tracking loyalty points.
The system operates with a simple menu-driven interface, where users can
choose food items, specify quantities, and view the total amount, which is
subject to discounts based on loyalty points. The project also provides the ability
to search, delete, and generate reports for customer orders. The data is saved in
CSV format for easy management and accessibility.
Modules:
1. Order Management Module:
o Take customer orders, choose items from the menu, and apply
discounts based on loyalty points.
o Generate unique order numbers and store order details.
2. Payment Module:
o Process payments via different methods (Credit/Debit Card, UPI,
Cash).
o Apply discounts for loyal customers if applicable.
3. Report Generation Module:
o Generate daily reports of all orders.
o Provide sales summaries and top-selling items.
o Display the most loyal customers based on points.
4. Data Management Module:
o Save customer orders to a CSV file.
o Provide search and delete functionalities for individual orders.
6|Page
o Support the deletion of all orders when required.
5. Loyalty Points System:
o Track and display customer loyalty points.
o Offer rewards for customers with high loyalty points.
Software Requirements:
• Programming Language: Python 3.6 or higher
• Libraries: datetime, csv, os, random
• IDE: Visual Studio Code, PyCharm, or any Python IDE
• Database: CSV files for data storage
7|Page
Modules/Functions/Variables Used
• import csv: Used to read and write data in CSV format for saving and
managing orders.
• import datetime: Used to fetch and display the current date and time.
• import random: Used to generate random values like order numbers and
loyalty points.
• import os: Used to handle file operations such as deleting files (for
deleting orders).
• print(): Used to display output on the console.
• input(): Used to take user input for ordering food, payment methods, etc.
• open(): Used to open files in read, write, or append mode.
• csv.reader(): Used to read data from a CSV file.
• csv.writer(): Used to write data into a CSV file.
• datetime.now(): Used to fetch the current date and time.
• random.randint(): Used to generate random values, such as order
numbers and loyalty points.
• str.format(): Used to format output strings with values (e.g., displaying
prices).
• if-elif-else: Used to make decisions based on user inputs (for menu
choices, payment methods, etc.).
• while loop: Used to keep the order-taking process running until the user
decides to finish.
• try-except: Used to handle errors, like invalid input or file operations.
• break: Used to exit loops (e.g., exit order loop when the user selects
option to finish).
• continue: Used to skip current iteration in a loop (e.g., when invalid input
is detected).
• float(): Used to convert the total amount and discount into floating-point
numbers for calculations.
8|Page
SOURCE
CODE
9|Page
import csv
from datetime import datetime
import random
import os
import time
file_name = 'food_orders.csv'
def display_menu():
print("\n=== FOOD MENU ===")
menu_items = {
1: ("Pizza", 10),
2: ("Burger", 5),
3: ("Pasta", 7),
4: ("Salad", 4),
5: ("Sandwich", 6),
6: ("Fries", 3),
7: ("Coffee", 2),
8: ("Juice", 4),
9: ("Ice Cream", 3),
10: ("Brownie", 5)
}
for key, value in menu_items.items():
print(f"{key}. {value[0]} - ${value[1]}")
print("11. Exit")
10 | P a g e
def take_order():
name = input("Enter customer's name: ")
loyalty_points = random.randint(0, 100)
print(f"Customer has {loyalty_points} loyalty points.")
display_menu()
order_number = random.randint(1000, 9999)
orders = []
total_amount = 0
while True:
try:
order_choice = int(input("Enter the item number you want to order (or
11 to finish): "))
if order_choice == 11:
break
quantity = int(input("Enter quantity: "))
menu_items = {
1: ("Pizza", 10),
2: ("Burger", 5),
3: ("Pasta", 7),
4: ("Salad", 4),
5: ("Sandwich", 6),
6: ("Fries", 3),
7: ("Coffee", 2),
8: ("Juice", 4),
9: ("Ice Cream", 3),
10: ("Brownie", 5)
11 | P a g e
}
if order_choice in menu_items:
item, price = menu_items[order_choice]
total_price = price * quantity
total_amount += total_price
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
orders.append((order_number, name, item, quantity, total_price,
timestamp))
print(f"Added: {item} x{quantity} - ${total_price}")
else:
print("Invalid choice. Please try again.")
except ValueError:
print("Invalid input. Please enter numbers only.")
discount = 0
if loyalty_points > 50:
discount = 0.1 * total_amount
print(f"Applying 10% discount for loyal customer! Discount: ${discount}")
final_amount = total_amount - discount
print(f"Total amount after discount: ${final_amount}")
payment_status = process_payment(final_amount)
if payment_status:
save_orders(orders)
else:
print("Payment failed. Order not saved.")
12 | P a g e
def process_payment(amount):
print("\n=== PAYMENT SYSTEM ===")
print(f"Total Amount: ${amount}")
print("1. Credit Card")
print("2. Debit Card")
print("3. UPI Payment")
print("4. Cash")
payment_choice = input("Choose a payment method: ")
def save_orders(orders):
with open(file_name, mode='a', newline='') as file:
writer = csv.writer(file)
for order in orders:
writer.writerow(order)
print("Order(s) saved successfully!")
def generate_report():
print("\n=== DAILY ORDERS REPORT ===")
try:
13 | P a g e
with open(file_name, mode='r') as file:
reader = csv.reader(file)
print(f"{'Order No.':<10}{'Customer Name':<15}{'Food
Item':<15}{'Quantity':<10}{'Total Price ($)':<15}{'Timestamp':<20}")
print("-" * 85)
for row in reader:
print(f"{row[0]:<10}{row[1]:<15}{row[2]:<15}{row[3]:<10}{row[4]:<15}{row[5]:<2
0}")
except FileNotFoundError:
print("No orders found!")
def search_order():
name_to_search = input("Enter the customer's name to search: ").capitalize()
found = False
try:
with open(file_name, mode='r') as file:
reader = csv.reader(file)
for row in reader:
if row[1].lower() == name_to_search.lower():
print(f"\nOrder found: {row}")
found = True
if not found:
print("No order found for this customer.")
except FileNotFoundError:
print("No orders found!")
14 | P a g e
def delete_order():
order_to_delete = input("Enter the order number to delete: ")
updated_orders = []
order_deleted = False
try:
with open(file_name, mode='r') as file:
reader = csv.reader(file)
for row in reader:
if row[0] != order_to_delete:
updated_orders.append(row)
else:
order_deleted = True
if order_deleted:
with open(file_name, mode='w', newline='') as file:
writer = csv.writer(file)
writer.writerows(updated_orders)
print("Order deleted successfully!")
else:
print("No order found with that order number.")
except FileNotFoundError:
print("No orders found!")
def sales_summary():
print("\n=== SALES SUMMARY REPORT ===")
price_list = {"Pizza": 10, "Burger": 5, "Pasta": 7, "Salad": 4, "Sandwich": 6,
"Fries": 3, "Coffee": 2, "Juice": 4, "Ice Cream": 3, "Brownie": 5}
sales_data = {item: 0 for item in price_list}
15 | P a g e
try:
with open(file_name, mode='r') as file:
reader = csv.reader(file)
for row in reader:
food_item = row[2]
quantity = int(row[3])
sales_data[food_item] += quantity
print(f"{'Food Item':<15}{'Total Quantity Sold':<20}")
print("-" * 35)
for item, quantity in sales_data.items():
print(f"{item:<15}{quantity:<20}")
except FileNotFoundError:
print("No orders found!")
def delete_all_orders():
confirm = input("Are you sure you want to delete all orders? (yes/no):
").lower()
if confirm == "yes":
if os.path.exists(file_name):
os.remove(file_name)
print("All orders deleted successfully!")
else:
print("No orders to delete.")
else:
print("Operation cancelled.")
def loyalty_points_system():
16 | P a g e
name = input("Enter customer's name: ")
points = random.randint(0, 100)
print(f"Customer {name} has {points} loyalty points!")
def display_datetime():
current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(f"Current Date and Time: {current_datetime}")
def top_selling_items():
print("\n=== TOP SELLING ITEMS ===")
try:
sales_data = {}
with open(file_name, mode='r') as file:
reader = csv.reader(file)
for row in reader:
item = row[2]
quantity = int(row[3])
if item in sales_data:
sales_data[item] += quantity
else:
sales_data[item] = quantity
sorted_sales = sorted(sales_data.items(), key=lambda x: x[1], reverse=True)
print(f"{'Food Item':<15}{'Total Sold':<10}")
print("-" * 25)
for item, qty in sorted_sales[:5]:
print(f"{item:<15}{qty:<10}")
17 | P a g e
except FileNotFoundError:
print("No orders found!")
def most_loyal_customers():
print("\n=== MOST LOYAL CUSTOMERS ===")
loyalty_data = {}
try:
with open(file_name, mode='r') as file:
reader = csv.reader(file)
for row in reader:
customer = row[1]
total_points = loyalty_data.get(customer, 0) + random.randint(1, 10)
loyalty_data[customer] = total_points
sorted_loyalty = sorted(loyalty_data.items(), key=lambda x: x[1],
reverse=True)
print(f"{'Customer Name':<20}{'Loyalty Points':<15}")
print("-" * 35)
for customer, points in sorted_loyalty[:5]:
print(f"{customer:<20}{points:<15}")
except FileNotFoundError:
print("No orders found!")
def main():
while True:
print("\n=== FOOD ORDERING SYSTEM ===")
print("1. Take Order")
print("2. Generate Report")
18 | P a g e
print("3. Search Order")
print("4. Delete Order")
print("5. Sales Summary Report")
print("6. Delete All Orders")
print("7. Display Loyalty Points")
print("8. Display Current Date and Time")
print("9. View Top Selling Items")
print("10. View Most Loyal Customers")
print("11. Exit")
if choice == '1':
take_order()
elif choice == '2':
generate_report()
elif choice == '3':
search_order()
elif choice == '4':
delete_order()
elif choice == '5':
sales_summary()
elif choice == '6':
delete_all_orders()
elif choice == '7':
loyalty_points_system()
19 | P a g e
elif choice == '8':
display_datetime()
elif choice == '9':
top_selling_items()
elif choice == '10':
most_loyal_customers()
elif choice == '11':
print("Exiting system. Thank you!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
20 | P a g e
Key Functions/Operations Used in the Project
1. MySQL Database Operations
• mysql.connector.connect() – Used to establish a connection between
Python and MySQL for database interactions.
• cursor() – Used to create a cursor object that executes SQL queries.
• execute() – Used to execute SQL commands (like SELECT, INSERT, UPDATE)
for interacting with the database.
• commit() – Used to commit transactions after executing SQL queries,
ensuring that changes are saved to the database.
• fetchall() – Retrieves all results from a database query.
2. File Operations
• csv.reader() – Reads CSV files to import order data or other necessary
details.
• csv.writer() – Writes the order details to a CSV file.
• open() – Opens files in various modes (read, write, append).
• close() – Closes the file after reading or writing.
• pickle.dump() – Saves data to a binary file (if binary file handling is part of
the system).
• pickle.load() – Loads data from a binary file.
3. Order Processing
• take_order() – This function manages the process of taking orders from
customers, calculating totals, and handling item selection.
• display_menu() – Displays the list of food items with prices from which
the customer can choose.
• generate_order_number() – Generates a unique order number for each
new order.
• process_payment() – Handles payment processing using different
methods (Credit Card, UPI, Cash).
21 | P a g e
• save_orders() – Saves all order details (order number, item, quantity,
price) to the database or CSV.
4. Loyalty Program
• calculate_loyalty_points() – Calculates and assigns loyalty points to
customers based on their spending.
• apply_discount() – Applies a discount to the total order if loyalty points
meet a threshold.
5. Report Generation
• generate_report() – Generates a report by fetching orders from the
database and displaying them in a structured format (order number,
customer, food item, quantity, etc.).
• sales_summary() – Displays a summary of total sales and quantities sold
for each food item.
• top_selling_items() – Lists the top-selling items based on the number of
units sold.
6. User Interaction
• input() – Used to take user inputs, such as order choice, quantity, and
payment method.
• print() – Used to display the menu, order summaries, and reports to the
user.
7. Time and Date
• datetime.now() – Fetches the current date and time to timestamp orders
or logs
22 | P a g e
SCIRPTS
1. Order Management Script
• take_order(): Manages the process of taking an order, including displaying
the menu, calculating the total, applying loyalty discounts, and processing
the payment.
• display_menu(): Displays the list of food items and their prices.
• process_payment(): Manages the payment process, allowing users to
choose different payment methods.
• save_orders(): Saves the orders to a CSV file for later retrieval or
reporting.
2. Reporting Scripts
• generate_report(): Generates a report of all orders stored in the
database, showing the order number, customer name, items, quantities,
and total price.
• sales_summary(): Provides a summary of the total sales, listing the
quantity of each food item sold.
• top_selling_items(): Shows the top-selling food items based on the
number of units sold.
• most_loyal_customers(): Displays a list of the most loyal customers based
on their accumulated loyalty points.
3. File Handling Scripts
• csv.reader() and csv.writer(): Used for reading from and writing to CSV
files, which store order data.
• pickle.dump() and pickle.load(): Used to write data to and read data from
binary files (if included in your project).
4. Database Interaction Scripts
• The script uses MySQL with Python connectivity to interact with a
database, executing commands like SELECT, INSERT, UPDATE, and DELETE.
23 | P a g e
5. Utility Scripts
• datetime.now(): Used for recording timestamps of orders.
• Random module (for loyalty points): Randomly generates loyalty points
for customers.
24 | P a g e
SCREENSHOTS OF INPUT AND OUTPUTS
25 | P a g e
26 | P a g e
27 | P a g e
28 | P a g e
BIBLIOGRAPY
1. Python Documentation - Official documentation for Python
programming language, providing insights into various libraries like
csv, datetime, and pickle.
(https://docs.python.org/)
2. MySQL Documentation - MySQL's official documentation for
understanding database connectivity and management in Python.
(https://dev.mysql.com/doc/)
3. W3Schools - A comprehensive online resource for learning SQL and
Python integration with databases.
(https://www.w3schools.com/)
4. GeeksforGeeks - Tutorials and articles on Python MySQL
connectivity and file handling.
(https://www.geeksforgeeks.org/)
5. Stack Overflow - Community-based platform for solving
programming-related queries, including Python and SQL issues.
(https://stackoverflow.com/)
29 | P a g e