Micro-Project Report
On
“ Bus Reservation System”
S u b m itte d by
Roll No. Name of Team Members
13 Rohit Layane.
15 Yuvraj Mugdyal.
17 Shubham Sakhare.
Program: Diploma in Electronics and Telecommunication Engineering
Cla ss : SYEJ (Semester III)
Co u rse : BPP (Subject Code: 313011)
G u ide d By
Prof. Vhatkar R.Y.
Department of Electronics And Telecommunications Engineering Vidya
Vikas Pratisthan Polytechnic, Solapur.
[2024 - 25]
CERTIFICATE
SYEJ (Semester III) have successfully completed the Micro -Project work titled “Bus Reservation System” in the BASIC PYTHON PROGRAMMING
(313011) of Program Diploma in Electronics and Telecommunication Engineering of M a h a ra sh tra S ta te o f T ec hn ic a l
Ed u ca t ion , M u m b a i, M a h a ra sh tra S ta te .
G uide H e a d of Dep artm en t Prin cipa l
Pro f . Vhatkar R.Y. P rof. W a g h K .H. Dr. S.N. Kulkarni
Da te : / /2024
Place: Solapur
Department of Electronics And Telecommunications Engineering Vidya
Vikas Pratisthan Polytechnic, Solapur.
[2023 - 24]
Undertaking by Students
W e w ill p re serv e m icro- proje ct a n d th e re port in o u r cu stod y t ill e n d o f c om pletion of ou r pro gra m . W e a ssu re th a t w e w ill p ro du c e th e sa m e
w ith o u t fail w h en e ve r w eo r a n yb od y from o u r gro u p w ill be a ske d to do so .
S Ro llNo . Na m e o f Stu den t M ob ile No. S ig na ture
r.
N
o
1 13 Rohit Layane 7821817701
2 15 Yuvraj Mugdyal 9021217772
3 17 Shubham Sakhare 8767777948
Micro-Project
On
"Bus Reservation System"
CODE :
class BusReservationSystem:
def __init__(self, bus_capacity):
"""Initialize the bus reservation system with a given bus capacity."""
self.bus_capacity = bus_capacity
self.seats = [None] * bus_capacity # None means the seat is available
def show_available_seats(self):
"""Display all available seats."""
available_seats = [i + 1 for i, seat in enumerate(self.seats) if seat is None]
if available_seats:
print("Available Seats:", available_seats)
else:
print("No seats available.")
def book_seat(self, seat_number, passenger_name):
"""Book a seat for a passenger."""
if seat_number < 1 or seat_number > self.bus_capacity:
print("Invalid seat number.")
return
if self.seats[seat_number - 1] is not None:
print(f"Seat {seat_number} is already booked by {self.seats[seat_number -
1]}.")
else:
self.seats[seat_number - 1] = passenger_name
print(f"Seat {seat_number} successfully booked for {passenger_name}.")
def cancel_reservation(self, seat_number):
"""Cancel the reservation for a given seat."""
if seat_number < 1 or seat_number > self.bus_capacity:
print("Invalid seat number.")
return
if self.seats[seat_number - 1] is None:
print(f"Seat {seat_number} is already vacant.")
else:
passenger_name = self.seats[seat_number - 1]
self.seats[seat_number - 1] = None
print(f"Reservation for seat {seat_number} by {passenger_name} has been
canceled.")
def show_bookings(self):
"""Display the current seat reservations."""
print("Current Bookings:")
for i, passenger in enumerate(self.seats):
seat_number = i + 1
if passenger:
print(f"Seat {seat_number}: {passenger}")
else:
print(f"Seat {seat_number}: Available")
def main():
print("Welcome to the Bus Reservation System")
bus_capacity = int(input("Enter the bus capacity: "))
bus_system = BusReservationSystem(bus_capacity)
while True:
print("\n1. Show Available Seats")
print("2. Book a Seat")
print("3. Cancel a Reservation")
print("4. Show Current Bookings")
print("5. Exit")
choice = input("Enter your choice (1-5): ")
if choice == '1':
bus_system.show_available_seats()
elif choice == '2':
seat_number = int(input("Enter seat number to book: "))
passenger_name = input("Enter your name: ")
bus_system.book_seat(seat_number, passenger_name)
elif choice == '3':
seat_number = int(input("Enter seat number to cancel: "))
bus_system.cancel_reservation(seat_number)
elif choice == '4':
bus_system.show_bookings()
elif choice == '5':
print("Thank you for using the Bus Reservation System!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
OUTPUT :
1. Initial Interaction:
Welcome to the Bus Reservation System
Enter the bus capacity: 5
1. Show Available Seats
2. Book a Seat
3. Cancel a Reservation
4. Show Current Bookings
5. Exit
Enter your choice (1-5): 1
Available Seats: [1, 2, 3, 4, 5]
2. Booking a Seat:
Enter your choice (1-5): 2
Enter seat number to book: 1
Enter your name: Alice
Seat 1 successfully booked for Alice.
3. Viewing Available Seats after booking:
Enter your choice (1-5): 1
Available Seats: [2, 3, 4, 5]
4. Canceling a Reservation:
Enter your choice (1-5): 3
Enter seat number to cancel: 1
Reservation for seat 1 by Alice has been canceled.
5. Viewing Current Bookings:
Enter your choice (1-5): 4
Current Bookings:
Seat 1: Available
Seat 2: Available
Seat 3: Available
Seat 4: Available
Seat 5: Available
6. Exiting the Program:
Enter your choice (1-5): 5
Thank you for using the Bus Reservation System!