0% found this document useful (0 votes)
20 views9 pages

Madhava PPS Min Pproject

The document describes a Python program for a hotel room booking system using a class called Hotel. The Hotel class initializes rooms in a dictionary, and has methods to display room status, book rooms, and check availability. The main function provides a user interface as a menu to interact with the hotel booking system by calling the Hotel class methods.

Uploaded by

mangalimadhava
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)
20 views9 pages

Madhava PPS Min Pproject

The document describes a Python program for a hotel room booking system using a class called Hotel. The Hotel class initializes rooms in a dictionary, and has methods to display room status, book rooms, and check availability. The main function provides a user interface as a menu to interact with the hotel booking system by calling the Hotel class methods.

Uploaded by

mangalimadhava
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/ 9

INTODUCTION:

Certainly! Below is a simple Python program for hotel


room booking. This program uses a dictionary to store
information about available rooms and their status
(booked or available). It includes functions for booking a
room, checking room availability, and displaying the list
of booked rooms. This program defines a Hotel class
with methods for displaying room status, booking a
room, and checking room availability. The main function
serves as the entry point for the program, where the
user can interact with the hotel booking system through
a simple menu. You can customize the number of rooms
and modify the program according to your specific
requirements.

CODE:
class Hotel:
def __init__(self, num_rooms):
self.rooms = {i: 'available' for i in range(1, num_rooms +
1)}

def display_rooms(self):
print("Room Status:")
for room_num, status in self.rooms.items():
print(f"Room {room_num}: {status}")

def book_room(self, room_num):


if room_num in self.rooms and self.rooms[room_num] ==
'available':
self.rooms[room_num] = 'booked'
print(f"Room {room_num} booked successfully.")
else:
print(f"Room {room_num} is not available.")

def check_availability(self, room_num):


if room_num in self.rooms:
return self.rooms[room_num]
else:
return "Invalid room number"

def main():
num_rooms = 10 # You can change the number of rooms as
needed
hotel = Hotel(num_rooms)

while True:
print("\nHotel Room Booking System")
print("1. Display Room Status")
print("2. Book a Room")
print("3. Check Room Availability")
print("4. Exit")

choice = input("Enter your choice (1/2/3/4): ")

if choice == '1':
hotel.display_rooms()
elif choice == '2':
room_num = int(input("Enter the room number to book:
"))
hotel.book_room(room_num)
elif choice == '3':
room_num = int(input("Enter the room number to check
availability: "))
status = hotel.check_availability(room_num)
print(f"Room {room_num} is {status}.")
elif choice == '4':
print("Exiting the program. Thank you!")
break
else:
print("Invalid choice. Please enter a valid option.")

if __name__ == "__main__":
main()
AlgOrIThm fOr hOTEl rOOm BOOkINg
SySTEm:

INITIAlIzE hOTEl:
Create a class Hotel with a constructor to initialize the
number of rooms and their initial status (available).
Display Room Status:
Create a method display_rooms in the Hotel class to
print the current status of all rooms.

BOOk A rOOm:
Create a method book_room in the Hotel class that
takes a room number as input.
Check if the room is valid and available.
If yes, mark the room as booked.
If no, display a message that the room is not available.

ChECk rOOm AvAIlABIlITy:


Create a method check_availability in the Hotel class
that takes a room number as input.
Check if the room is valid and return its current status
(available or booked).

USEr INTErfACE (mAIN fUNCTION):


Create a main function to serve as the entry point for the
program.
Inside the main function, use a loop to continuously
present a menu to the user.

DISplAy OpTIONS:
Display Room Status
Book a Room
Check Room Availability
Exit
Based on the user's choice, call the corresponding
method from the Hotel class.

ExIT:
Provide an option to exit the program when the user is
done.

flOW ChArT:

Start Program

Display
Menu
1. Display
2. Book
3. Check
4. Exit

User Chooses
Option

Option 1:
Display Room
Status

Display Room
Status Function

Display
Room Status

Enter Room
Number

Return to Menu

Option 2:
Book a Room
Return to Menu

Option 4:
Exit Program

End
Program
Book a Room
Function

Book Room
Function

Room Booked

Return to Menu

Option 3:
Check Availability

Check
Availability Function

Enter Room
Number

Display
Availability.

You might also like