Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lets imagine A newly established airline has signed a contract with us to create a seat reservation system planes in python. In this example we

Lets imagine A newly established airline has signed a contract with us to create a seat reservation system planes in python. In this example we use a plane that has 8 rows of seats, 4 seats in each row and corridor in the middle (see example). Write a program that allows a user to choose a seat and keeps track of which seats are booked and which seats are available When the program prints out the seating arrangement, available seats are represented by '_' and reserved seats denoted by 'X'. At the beginning, all seats are available. User can select a seat by writing numbers for row and seat with a comma in between. If the seat is free, the program indicates that this seat has now been reserved, but if the seat is busy, the program prints a message to that effect. The program should continue retrieving seat reservations from the user until the user types 'quit'. That it can be assumed that the user does not make mistakes, i.e. user always writes either legal coordinates or 'quit'. At the end, the program should print out how many seats were booked. For the program to receive full points, it must contain at least one good function and use constants where appropriate on. The main part should be short and to the point. Also, in order for the program to receive full points, it should be very easy to adapt the program in any way planes, both in terms of the number of rows of seats, the number of seats in each row and how it works the plane are. The printing output have to look like in examples Examples:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: 0,0 Seat 0 in row 0 is now booked. X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: 7.3 Seat 3 in row 7 is now booked. X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ X Select a seat: 3.2 Seat 2 in row 3 is now booked. X _ _ _ _ _ _ _ _ _ _ _ _ _ X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ X Select a seat: 3.2 Sorry, seat 2 in row 3 is occupied. X _ _ _ _ _ _ _ _ _ _ _ _ _ X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ X Select a seat: 0,0 Sorry, seat 0 in row 0 is occupied. X _ _ _ _ _ _ _ _ _ _ _ _ _ X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ X Select a seat: quit You booked 3 seats. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: 3.1 Seat 1 in row 3 is now booked. _ _ _ _ _ _ _ _ _ _ _ _ _ X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: 3.1 Sorry, seat 1 in row 3 is occupied. _ _ _ _ _ _ _ _ _ _ _ _ _ X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: quit You booked 1 seat. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: quit You booked 0 seats. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: 7.3 Seat 3 in row 7 is now booked. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ X Select a seat: 7.0 Seat 0 in row 7 is now booked. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ X _ _ X Select a seat: quit You booked 2 seats. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: 1.1 Seat 1 in row 1 is now booked. _ _ _ _ _ X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: 1.1 Sorry, seat 1 in row 1 is occupied. _ _ _ _ _ X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: 1.1 Sorry, seat 1 in row 1 is occupied. _ _ _ _ _ X _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Select a seat: quit You booked 1 seat.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions