Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_valid_num(num):
- NUMBERS = ["0","1","2","3","4","5","6","7","8","9"]
- SIGNS = ["+","-"]
- for i in range(len(num)):
- if i==0:
- if num[i] not in SIGNS+NUMBERS:
- return False
- elif num[i] not in NUMBERS:
- return False
- return True
- print("""
- Available Seats: 50
- Business Class: Rs.15000 per seat
- Economy Class: Rs.7500 per seat
- """)
- TOTAL_SEAT = 50
- remaining_seat=50
- while True:
- seat_type = input("Enter class (Business|Economy) for reservation:\n")
- if seat_type != "Business" and seat_type != "Economy":
- print("Invalid class choice. Please enter Business or Economy.")
- continue
- per_seat_cost=7500
- if seat_type=="Business":
- per_seat_cost = 15000
- num_seat = input("Enter the number of seats to reserve: ")
- if not is_valid_num(num_seat):
- print("Invalid input. Please enter a valid number.")
- continue
- if int(num_seat)>remaining_seat:
- print(f"Invalid number of seats. Available seats: {remaining_seat}")
- else:
- num_seat = int(num_seat)
- remaining_seat-=num_seat
- print(f"Reservation successful! Total cost: Rs.{num_seat*per_seat_cost}")
- reserve_again = input("Do you want to make another reservation?\n(yes|no): ")
- if reserve_again == "yes":
- continue
- else:
- break
- print("Boarding Passes:")
- for i in range(TOTAL_SEAT-remaining_seat):
- print(f"Seat {i+1} - Boarding Pass")
- print("Thank you for using our reservation system!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement