0% found this document useful (0 votes)
2 views

Computer Science project

Uploaded by

asavari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Computer Science project

Uploaded by

asavari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

ATOMIC ENERGY CENTRAL SCHOOL-4

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.

First, we are grateful to our Principal Shri Santhosh


Jhadav next our Computer Science teacher Smt. Rani
Sastry who have guided us to complete this project
successfully.

I am deeply indebted to them for their valuable


Suggestions and unconditional support. We are also
thankful to our parents and our friends who
Have helped us at various stages of this 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

username and password.


 If the username is "admin" and the

password is "admin123", proceed to the


seller's menu.
 Else, prompt again for valid login

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:

1. Add a new book.


2. View all books.
3. Search for a book.
4. Delete a book.
5. Update a book.
6. Exit.
5
o Based on the user's choice
 Add Book: Ask for book details

(number, name, author, price) and


store in a file.
 View All Books: Display all book details.

 Search Book: Ask for book number and

display the book's details.


 Delete Book: Ask for book number and

remove the book.


 Update Book: Ask for book number and

update the details.


 Exit: End the program.

4. Customer Menu (if the user is a customer):


o Show the menu with options:

0. View all books.


1. Search for a book.
2. Exit.
o Based on the user's choice,

 View All Books: Display all books

available.
 Search Book: Ask for book number and

display the details of the book.


 Exit: End the program.End

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.")

# Function to delete a book by number


def delete_book():
try:
F=open('book.dat', 'rb'):
books = []
bno = int(input("Enter the book number to delete: "))
found = False
9
while True:
try:
t = pickle.load(f) # Load each book record
if t[0] != bno:
books.append(t)
else:
found = True
except EOFError:
break
if found:
# Rewrite the file without the deleted book
f= open('book.dat', 'wb') :
for book in books:
pickle.dump(book, f)
print(f"Book with number {bno} has been deleted.")
else:
print(f"Book with number {bno} not found.")
except FileNotFoundError:
print("No books found. Please add books first.")

# Function to update book details by number


def update_book():
try:
f= open('book.dat', 'rb'):
books = []
bno = int(input("Enter the book number to update: "))
found = False
while True:
try:
10
t = pickle.load(f)
if t[0] == bno:
# Book found, update details
print(f"Current details: (T))
t[1] = input("Enter new name: ")
t[2] = input("Enter new author: ")
t[3] = float(input("Enter new price: "))
found = True
books.append(t) # Add book to list (updated or not)
except EOFError:
break
if found:
# Rewrite the file with updated details
F=open('book.dat', 'wb') :
for book in books:
pickle.dump(book, f)
print(f"Book with number {bno} has been updated.")
else:
print(f"Book with number {bno} not found.")
except EOFError:
print("No books found. Please add books first.")
# Function to exit the program
def exitprogram():
print("Exiting program...")
exit()
# Login function to handle seller and customer logins
def login():
print("Welcome to the Book Store Management System")

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)

Seller Login: Customer Login:

Seller Menu (After Logging in as Seller)

Viewing all books (seller): Searching for a book as a seller

r
14
Updating a book (seller) Deleting a book

Exiting the program Customer Menu

Searching a book as a customer Exiting a program(customer)

15
BIBLIOGRAPHY

 Help from Teachers

 Internet(website name)

 Computer Science Textbook

16

You might also like