Computer Science project
Computer Science project
COMPUTER SCIENCE
INVESTIGATORY PROJECT
PROGRAM FOR
Book Store Management
MADE BY
Name: EESHITA S BHELAWE
Class: 12
Roll No: 25
Board Roll No: 15137023
1
ACKNOWLEDGEMENT
A heartfelt gratitude to those who have played
Inspirational role in successful completion of this
Investigatory Project.
2
CERTIFICATE
This is to certify that Eeshita Bhelawe of class
12 A Board Roll No.15137023 of 2024-25 batch
of this school have successfully completed this
Investigatory project in Computer Science
under the guidance of Smt.Rani Sastry
(Computer Science teacher) in partial fulfilment
of computer practical examination conducted
by AECS-4, Anushakti Nagar
Mumbai-400094.
______________ ______________
SUBJECT TEACHER INTERNAL EXAMINER
________________ ________________
EXTERNAL EXAMINER Principal Sir
3
INDEX
SR.NO. CONTENTS PAGE NO.
1. ALGORITHM 5
2. FLOWCHART 7
3. CODE OF 8
PROGRAM
4. OUTPUT OF 14
PROGRAM
5. BIBLIOGRAPHY 16
4
Algorithm
1. Start
2. Login Process:
o Prompt the user to enter "seller" or
"customer".
o If the user selects "seller", ask for the
credentials.
o If the user selects "customer", automatically
log in.
3. Seller Menu (if the user is a seller):
o Show the menu with options:
available.
Search Book: Ask for book number and
6
FLOWCHART
7
CODE OF THE PROGRAM
import pickle
# Function to create the binary file and add book details
def createfile():
with open('book.dat', 'wb') as f:
while True:
# Taking book details as input
bno = int(input("Enter the book number: "))
bname = input("Enter the book name: ")
author = input("Enter the author: ")
price = float(input("Enter the price: ")
data = [bno, bname, author,price]
pickle.dump(data, f)
ch = input("More records (y/n)? ")
if ch.upper() == 'N':
break
print("Books have been saved successfully!")
# Function to view all books from the binary file
def viewfile():
try:
f=open('book.dat', 'rb')
print("\n--- All Books ---")
try:
while True:
t = pickle.load(f)
print(t)
except EOFError:
pass
8
except EOFError:
print("No books found. Please add books first.")
# Function to search for a book by number
def search_book():
try:
with open('book.dat', 'rb') as f:
bno = int(input("Enter the book number to search: "))
found = False
while True:
try:
t = pickle.load(f) # Load each book record
if t[0] == bno:
print(f"Book Found: {t}")
found = True
break
except EOFError:
break
if not found:
print("Book not found.")
except EOFError:
print("No books found. Please add books first.")
11
user_type = input("Enter 'seller' to log in as seller or
'customer' to log in as customer: ").lower()
if user_type == "seller":
username = input("Enter username: ")
password = input("Enter password: ")
if username == "admin" and password == "admin123":
print("Logged in as seller.")
return user_type
else:
return login()
print("Invalid credentials. Please try again.” )
elif user_type == "customer":
print("Logged in as customer.")
return user_type
else:
print("Invalid user type. Please choose 'seller' or 'customer'.")
return login()
# Main function to run the library management system
def main():
user_type = login() # Login based on user type
while True:
print("\nLibrary Management System")
if user_type == "seller":
print("1. Add Book")
print("2. View All Books")
print("3. Search Book by Number")
print("4. Delete Book by Number")
print("5. Update Book by Number")
print("6. Exit")
12
choice = input("Enter your choice: ")
if choice == '1':
createfile()
elif choice == '2':
viewfile()
elif choice == '3':
search_book()
elif choice == '4':
delete_book()
elif choice == '5':
update_book()
elif choice == '6':
exit_program()
else:
print("Invalid choice, please try again.")
elif user_type == "customer":
print("1. View All Books")
print("2. Search Book by Number")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == '1':
viewfile()
elif choice == '2':
search_book()
elif choice == '3':
exit_program()
else:
print("Invalid choice, please try again.")
main()
13
OUTPUT
Logging In (Seller or Customer)
r
14
Updating a book (seller) Deleting a book
15
BIBLIOGRAPHY
Internet(website name)
16