Implement a C program that manages seat bookings for an event.
-
Seats:
[-1, -1, 0, 1, 2]
. Here,-1
indicates the seat is not available, and any non-negative integer indicates the seat number. -
Emails:
["test1@gmail.com", "test2@gmail.com", "test3@gmail.com"]
. -
The program should display the following options:
- View all seats booked
- View all seats available
- Clear all seats booked
- New seat booking
- Option 1: Display all the seats with seat number and email.
Example:
2: test1@gmail.com
3: test2@gmail.com
4: test3@gmail.com
- Option 2: Display all available seats for new booking.
Example:
0: Free
1: Free
- Option 3: Clear all the bookings and display the list of available seats.
Example:
0: Free
1: Free
2: Free
3: Free
4: Free
- Option 4: Allow the user to book a new seat.
Example:
0: Free
1: Free
2: Free
3: Free
4: Free
Select the seat number:
Enter email address:
The email address provided by the user should be validated. If the email is not in a valid format, prompt the user to enter it again.
- A seat can only be booked by one email at a time.
- The email validation should check for the presence of the '@' symbol and a domain. For the purpose of this challenge, you can consider an email to be valid if it contains the '@' symbol and a dot (.) after the '@' symbol.
- Seats:
[-1, -1, 0, 1, 2]
- Emails:
["test1@gmail.com", "test2@gmail.com", "test3@gmail.com"]
As specified above based on user's choice.
Note: Implement the program ensuring proper user input handling. If a user tries to book an already booked seat, the program should handle such cases gracefully.