CS Project Copy
CS Project Copy
COMPUTER SCIENCE
PROJECT
TOPIC:
Café Management
Submitted by: -
Name: Alric Pareira
Class: XII-A
Roll no: 6
TOPIC
Café
Management
CERTIFICATE
This is to certify that Alric Pareira of class XII A of St.
Arnold’s Central School has done his project on Cafe
Management under my supervision. He has taken
interest and has shown at most sincerity in completion
of this project.
Principal
ACKNOWLEDGEMENT
It is with pleasure that I acknowledge my sincere
gratitude to our teacher, Mrs.Elizabeth Emmanuel who
taught and undertook the responsibility of teaching the
subject computer science. I have been greatly benefited
from her classes.
Abstract..........................................................................................................................................7
Algorithm.......................................................................................................................12-14
Code......................................................................................................................................15-19
SQL Table...............................................................................................................................19
Sample Output.........................................................................................................20-24
Bibliography………………………………………………………………………………….…….25
ABSTRACT
The Cafe Management System is a Python-based
application designed to streamline café operations by
integrating a user-friendly interface with a robust
database. This system enables cafe managers to
efficiently manage menu items, process customer orders,
and generate accurate bills. The project leverages SQL to
maintain a structured database that includes two primary
tables: the Menu Table for storing drink details and the
Orders Table for recording transaction data.
display_m( ) function
order( ) function
Define the function.
Open file bill.txt in write mode.
Accept the order from the user.
Add the order along with the price to bill.txt.
Ask whether the user wants to bill out or add more
orders.
If the user chooses to add more orders, send the
command back to accepting the order.
If the user chooses to bill out, call the bill( )
function.
bill( ) function
ter( ) function
Define the function.
Terminate the program
Code
import sqlite3
from datetime import datetime
conn = sqlite3.connect('cafe.db')
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS Menu (
item_id INTEGER PRIMARY KEY
AUTOINCREMENT,
item_name TEXT NOT NULL,
item_price REAL NOT NULL
)''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS Orders (
order_id INTEGER PRIMARY KEY
AUTOINCREMENT,
item_name TEXT NOT NULL,
quantity INTEGER NOT NULL,
total_price REAL NOT NULL,
order_date TEXT NOT NULL
)''')
def add_menu_item():
item_name = input("Enter the name of the
drink: ")
item_price = float(input("Enter the price of
the drink: "))
cursor.execute("INSERT INTO Menu
(item_name, item_price) VALUES (?, ?)",
(item_name, item_price))
conn.commit()
print("Item added successfully!")
def remove_menu_item():
item_id = int(input("Enter the item ID to
remove: "))
cursor.execute("DELETE FROM Menu
WHERE item_id = ?", (item_id,))
conn.commit()
print("Item removed successfully!")
def display_menu():
cursor.execute("SELECT * FROM Menu")
menu = cursor.fetchall()
if menu:
print("\n--- Menu ---")
for item in menu:
print(f"{item[0]}. {item[1]} - ₹
{item[2]}")
else:
print("No items in the menu.")
def take_order():
order_list = []
while True:
display_menu()
item_id = int(input("Enter the item ID to
order (0 to stop): "))
if item_id == 0:
break
quantity = int(input("Enter the quantity:
"))
cursor.execute("SELECT item_name,
item_price FROM Menu WHERE item_id = ?",
(item_id,))
item = cursor.fetchone()
if item:
item_name, item_price = item
total_price = item_price * quantity
order_list.append((item_name,
quantity, total_price))
else:
print("Invalid item ID.")
if order_list:
print("\n--- Bill ---")
grand_total = 0
for order in order_list:
print(f"{order[0]} x {order[1]} =
₹{order[2]}")
grand_total += order[2]
cursor.execute("INSERT INTO Orders
(item_name, quantity, total_price,
order_date) VALUES (?, ?, ?, ?)",
(order[0], order[1], order[2],
datetime.now().strftime("%Y-%m-
%d %H:%M:%S")))
print(f"Grand Total: ₹
{grand_total}")
conn.commit()
def main():
while True:
print("\n--- Café Management System
---")
print("1. Add Menu Item")
print("2. Remove Menu Item")
print("3. Display Menu")
print("4. Take Order")
print("5. Exit")
choice = int(input("Enter your choice:
"))
if choice == 1:
add_menu_item()
elif choice == 2:
remove_menu_item()
elif choice == 3:
display_menu()
elif choice == 4:
take_order()
elif choice == 5:
print("Thank you for using the
Café Management System!")
break
else:
print("Invalid choice. Please try
again.")
if __name__ == "__main__":
main()
SQL Table
Sample Output
--- Cafe Management System ---
1. Add Menu Item
2. Remove Menu Item
3. Display Menu
4. Take Order
5. Exit
Enter your choice: 3
Bibliography
Computer science with python textbook for
classXII by sumit Arora.
learnpython4cbse.com
Thonny
SQL
Jupyter