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

Computer Science Project

Uploaded by

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

Computer Science Project

Uploaded by

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

ACKNOWLEDGMENT

I would like to express my special thanks of


gratitude to my teacher as well as our principal
who gave me this golden opportunity to do this
wonderful project on the topic [Hotel
booking management], which also helped me
in doing a lot of research and I came to know
about so many new things I am really thankful
to them.

PRIYANSHU PRASAD
Hardware & Software Requirement

#Software Specifications:
Operating System: - Windows 10 or up
Platform: - Python IDLE 3.12 64 bit
Database: - MySQL
Language: - Python

#Hardware Specifications:
Processor: - Intel i5 10th Generation
Hard Disk: - 512 GB
RAM: - 20gb
Content:

Seria Topic Pag


l No. e
No.
1 Certificate

2 Acknowledge

3 Hardware &
Software
Requirement
4 Content

5 Introduction

6 Problem analysis and solution

7 Uses of the program

8 How to use the program

9 Source code

10 Creating a table in sql

11 Outputs

12 Mysql outputs

13 References
Introduction
In today’s fast-paced world, the hospitality
industry is increasingly relying on technology to
enhance customer experience and streamline
operations. The Hotel Booking Management
System is a comprehensive solution designed to
automate and simplify the process of booking
hotel rooms. This system aims to provide a
seamless experience for both hotel administrators
and guests by integrating various functionalities
such as room availability checks, booking
confirmations, and payment processing.
The primary objective of this project is to develop
a user-friendly, web-based application that allows
hotel managers to efficiently manage room
reservations, track occupancy rates, and handle
customer inquiries. Guests can easily browse
available rooms, make reservations, and receive
instant confirmations, all from the comfort of their
homes. By leveraging modern web technologies,
this system ensures real-time updates and secure
transactions, thereby enhancing the overall
efficiency and reliability of hotel operations.
This project not only aims to improve the booking
process but also to provide valuable insights
through data analytics, helping hotel management
make informed decisions. With features like
automated reminders, feedback collection, and
personalized services, the Hotel Booking
Management System is poised to revolutionize the
way hotels operate, ensuring a superior
experience for guests and a streamlined workflow
for staff.
Problem Definition for Hotel Reservation System
Hotels require efficient reservation systems to manage guest
bookings, room availability, and customer information.
Traditional manual booking processes are often time-
consuming, prone to errors, and inconvenient for both hotel
staff and customers.

Problem Statement
Develop a comprehensive hotel reservation system that
automates and streamlines the process of booking rooms,
registering users, managing room availability, and viewing
reservations.

Problem Analysis for Hotel Reservation System


Objective
Create a comprehensive hotel reservation system that
allows users to register, login, manage room availability,
book rooms, and view their reservations.

Key Functionalities
User Registration and Login:

Registration: Users can register by providing their


username, password, and email.

Login: Users can log in with their username and password.

Room Management:
Add Room: Admins can add new rooms with specific details
like room number, type, and price.

View Available Rooms: Users can view the list of rooms that
are available for booking.

Booking System:

Book Room: Users can book rooms by providing their user


ID, room ID, check-in date, and check-out date.

Update Room Availability: Once a room is booked, its


availability status is updated.

Reservation Management:

View Reservations: Users can view their booking history and


upcoming reservations.

Problems Identified
Indentation Errors: Some parts of the code have improper
indentation, which can cause syntax errors and unexpected
behavior.

Typographical Errors: There are minor typos, particularly in


the elif statement in the main function.
Database Connection: If the database connection details
are incorrect or if the database server is not running, the
system will fail.

Password Storage: Passwords are stored in plain text,


which is a security risk. Implement hashing for password
storage.

Proposed Solutions
Fix Indentation: Ensure all functions and control structures
have proper indentation to avoid syntax errors.

Correct Typographical Errors: Adjust any typos in the


control flow statements to ensure logical execution.

Validate Database Connection: Check and handle potential


connection errors to make the system more robust.

Improve Security: Use hashing algorithms (like bcrypt) for


storing passwords securely.
This program can be highly useful for several reasons:

Convenience: Users can easily book rooms, view available


options, and manage their reservations online, without
needing to call or visit in person.

Efficiency: The automated system reduces the workload for


hotel staff, allowing them to focus on other important tasks
like customer service.

Accessibility: With 24/7 availability, users can make


reservations at their convenience, from anywhere in the
world.

Data Management: The program centralizes all information


regarding rooms and reservations, making it easier to
manage and update records.

Security: By incorporating secure password handling and


potentially adding encryption for sensitive data, the
program can protect user information.

Scalability: The program can be expanded to include more


features like payment processing, user reviews, and special
offers, making it a comprehensive solution for hotel
management.
Step-by-step guide on how to use this program:

Step 1: Set Up the Database


Install MySQL: Ensure you have MySQL installed and
running on your local machine or server.
Create Database: Create a database named
hotel_reservation.
Set Up Tables: Define the tables (users, rooms,
reservations) with the necessary fields such as username,
password, email, room_number, room_type, price,
availability, etc.

Step 2: Set Up Your Python Environment


Install MySQL Connector: Use pip to install the MySQL
connector: open your command prompt
And run the following command
‘pip install mysql-connector-python’.

Step 3: Run the Program


Execute the Script: Run the Python script containing your
hotel reservation system.

Step 4: Register and Login Users


Register: Choose the “Register” option from the main
menu, then input the required details (username,
password, email).

Login: Choose the “Login” option, input your username and


password, and verify your credentials.
Step 5: Room Management
View Rooms: After logging in, choose the “View Rooms”
option to see available rooms.

Step 6: Book a Room


Book Room: Choose the “Book Room” option and input the
required details (user ID, room ID, check-in date, check-out
date) to reserve a room.

Step 7: View Reservations


View Reservations: Choose the “View Reservations” option
and input your user ID to see your booking history.

Step 8: Exit
Exit the Program: Choose the “Exit” option to safely
terminate the program.
Source Code:

#database connection
import mysql.connector

def create_connection():
return mysql.connector.connect(
host="localhost",
user="root",
password="123456789",
database="hotel_reservation"
)
#user registration and login
def register_user(username, password, email):
conn = create_connection()
cursor = conn.cursor()
cursor.execute("INSERT INTO users (username, password, email)
VALUES (%s, %s, %s)", (username, password, email))
conn.commit()
cursor.close()
conn.close()
def login_user(username, password):
conn = create_connection()
cursor = conn.cursor()
cursor.execute("SELECT * FROM users WHERE username = %s AND
password = %s", (username, password))
user = cursor.fetchone()
cursor.close()
conn.close()
return user
#Room management
def add_room(room_number, room_type, price):
conn = create_connection()
cursor = conn.cursor()
cursor.execute("INSERT INTO rooms (room_number, room_type,
price) VALUES (%s, %s, %s)", (room_number, room_type, price))
conn.commit()
cursor.close()
conn.close()

def view_rooms():
conn = create_connection()
cursor = conn.cursor()
cursor.execute("SELECT * FROM rooms WHERE availability = TRUE")
rooms = cursor.fetchall()
cursor.close()
conn.close()
return rooms

#booking a room
def book_room(user_id, room_id, check_in, check_out):
conn = create_connection()
cursor = conn.cursor()
cursor.execute("INSERT INTO reservations (user_id, room_id,
check_in, check_out) VALUES (%s, %s, %s, %s)", (user_id, room_id,
check_in, check_out))
cursor.execute("UPDATE rooms SET availability = FALSE WHERE
room_id = %s", (room_id,))
conn.commit()
cursor.close()
conn.close()

#viewing reservations
def view_reservations(user_id):
conn = create_connection()
cursor = conn.cursor()
cursor.execute("SELECT * FROM reservations WHERE user_id =
%s", (user_id,))
reservations = cursor.fetchall()
cursor.close()
conn.close()
return reservations

#Main program
def main():
while True:
print("1. Register")
print("2. Login")
print("3. View Rooms")
print("4. Book Room")
print("5. View Reservations")
print("6. Exit")
choice = input("Enter choice: ")
if choice == '1':
username = input("Enter username: ")
password = input("Enter password: ")
email = input("Enter email: ")
register_user(username, password, email)
print("User registered successfully!")

elif choice == '2':


username = input("Enter username: ")
password = input("Enter password: ")
user = login_user(username, password)
if user:
print("Login successful!")
else:
print("Invalid credentials!")

elif choice == '3':


rooms = view_rooms()
for room in rooms:
print(room)

elif choice == '4':


user_id = int(input("Enter your user ID: "))
room_id = int(input("Enter room ID: "))
check_in = input("Enter check-in date (YYYY-MM-DD): ")
check_out = input("Enter check-out date (YYYY-MM-DD): ")
book_room(user_id,room_id,check_in,check_out)
print("Room booked successfully!")

elif choice == '5':


user_id = int(input("Enter your user ID: "))
reservations = view_reservations(user_id)
for reservation in reservations:
print(reservation)
elif choice == '6':
break

if __name__ == "__main__":
main()

note * (we have to create a database and structure tables in sql in order to use it in python)
Creating a table in sql:

CREATE DATABASE hotel_reservation;

USE hotel_reservation;

CREATE TABLE users (


user_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
email VARCHAR(100) NOT NULL
);
CREATE TABLE rooms (
room_id INT AUTO_INCREMENT PRIMARY KEY,
room_number INT NOT NULL,
room_type VARCHAR(50) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
availability BOOLEAN NOT NULL DEFAULT TRUE
);

CREATE TABLE reservations (


reservation_id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
room_id INT,
check_in DATE,
check_out DATE,
FOREIGN KEY (user_id) REFERENCES users(user_id),
FOREIGN KEY (room_id) REFERENCES rooms(room_id)
);

OUTPUTS:
#main program
Output:
View rooms:

Mysql outputs:
Reference
 Computer Science with Python Class XI by
Sumita Arora
Computer Science with Python Textbook for Class 11 : Sumita Arora: Amazon.in:
Books
 Computer Science with Python Class XII by
Sumita Arora
Progress In Computer Science With Python... by Sumita Arora (amazon.in)
 Python IDLE
Download Python | Python.org
 MySQL
MySQL :: MySQL Downloads

You might also like