Question

In: Computer Science

A theater seating chart is implemented as a table of ticket prices, like this C1 C2...

A theater seating chart is implemented as a table of ticket prices, like this
C1 C2 C3 C4 C5 C6 C7 C8 C9 C10
R1 10 10 10 10 10 10 10 10 10 10
R2 10 10 10 10 10 10 10 10 10 10
R3 10 10 10 10 10 10 10 10 10 10
R4 10 10 20 20 20 20 20 20 10 10
R5 10 10 20 20 20 20 20 20 10 10
R6 10 10 20 20 20 20 20 20 10 10
R7 20 20 30 30 30 30 30 30 20 20
R8 20 30 30 40 50 50 40 30 30 20
R9 30 40 50 50 50 50 50 50 40 30
R10 20 40 50 50 50 50 50 50 40 20

A theater seating chart is implemented as a table of ticket prices, like this above Write a program that asks users to pick either a seat or a price. When choosing seat, indicate the row and column for the location; when choosing the price, like computer find the first available price; mark the sold seats by changing the price to 0. When a user specifies a seat, make sure it is available. Use loop to determine whether continue to order or not. In each time, the seating chart should be displayed for user. When user stops ordering, your program should output the number of tickets ordered, and amount ordered.

PS- the program is being written in python language and our insturctor has told us to us elif

Solutions

Expert Solution

"""
Author:
Date:
File Name: ticket_booking.py
"""


def print_seats(data):
    """

    :param data:
    :return:
    """
    print("    ", end="")
    for i in range(len(data[0])):
        print("{0:>3s}".format("C" + str(i + 1)), end=" ", sep="")

    for i, row in enumerate(data):
        print("\n{0:>3s}".format("R" + str(i + 1)), end=" ", sep="")
        for column in row:
            print("{0:>3s}".format(str(column)), end=" ", sep="")

    print()


def menu():
    print("1.Pick Seat")
    print("2.Pick Price")
    print("3.Quit")


def book_by_seat(data, booked):
    """

    :param data:
    :param booked:
    :return:
    """
    while True:
        print_seats(data)
        row_number = int(input("Enter row number:"))
        col_number = int(input("Enter column number:"))
        if data[row_number - 1][col_number - 1] != 0:
            booked.append((row_number, col_number, data[row_number - 1][col_number - 1]))
            data[row_number - 1][col_number - 1] = 0
            print("Your ticked booked successfully")
        else:
            print("This seat is already booked.")
        opt = input("Do you want choose another one?y/n:")
        if opt.lower() == "n":
            print_seats(data)
            break


def book_by_price(data, booked):
    """

    :param data:
    :param booked:
    :return:
    """
    while True:
        print_seats(data)
        price = int(input("Enter Price:"))
        flag = True
        for i, row in enumerate(data):
            for j, col in enumerate(row):
                if col == price:
                    data[i][j] = 0
                    booked.append(((i + 1), (j + 1), price))
                    flag = False
                    print("Your ticked booked successfully")
                    break
            if not flag:
                break
        if flag:
            print("No ticket available at this price")
        opt = input("Do you want choose another one?y/n:")
        if opt.lower() == "n":
            print_seats(data)
            break


if __name__ == '__main__':
    table = [
        [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        [10, 10, 20, 20, 20, 20, 20, 20, 10, 10],
        [10, 10, 20, 20, 20, 20, 20, 20, 10, 10],
        [10, 10, 20, 20, 20, 20, 20, 20, 10, 10],
        [20, 20, 30, 30, 30, 30, 30, 30, 20, 20],
        [20, 30, 30, 40, 50, 50, 40, 30, 30, 20],
        [30, 40, 50, 50, 50, 50, 50, 50, 40, 30],
        [20, 40, 50, 50, 50, 50, 50, 50, 40, 20],
    ]
    booked_seat = []
    while True:
        menu()
        option = int(input("Choose your option:").strip())
        if option == 3:
            break
        elif option == 1:
            book_by_seat(table, booked_seat)

        elif option == 2:
            book_by_price(table, booked_seat)

    amount = 0
    for ticket in booked_seat:
        amount += ticket[2]
    print("Total Number Of Ticket:", len(booked_seat))
    print("Total Amount:", amount)

output:


Related Solutions

*****IN JAVA**** Implement a theater seating chart  as a two-dimensional array of ticket prices, like this: {10,...
*****IN JAVA**** Implement a theater seating chart  as a two-dimensional array of ticket prices, like this: {10, 10, 10, 10, 10, 10, 10, 10, 10, 10} {10, 10, 10, 10, 10, 10, 10, 10, 10, 10} {10, 10, 10, 10, 10, 10, 10, 10, 10, 10} {10, 10, 20, 20, 20, 20, 20, 20, 10, 10} {10, 10, 20, 20, 20, 20, 20, 20, 10, 10} {10, 10, 20, 20, 20, 20, 20, 20, 10, 10} {20, 20, 30, 30, 40,...
(c++ code) A theatre seating chart is implemented as a two-dimensional array of ticket prices, like...
(c++ code) A theatre seating chart is implemented as a two-dimensional array of ticket prices, like this:                 AISLE ROW      1           2             3             4             5             6             7             8             9              10 -------------------------------------------------------------------------------------------------------------- 10           10           10           10           10           10           10           10           10           10           10 9             10           10           10           10           10           10           10           10           10           10 8             10           10           10           10           10           10           10           10           10           10 7             10           10           20           20           20           20           20           20           10           10 6             10           10           20           20          ...
Theater tickets for a hit show have four prices depending on seating. The prices ae $50,...
Theater tickets for a hit show have four prices depending on seating. The prices ae $50, $100, $150 and $200. The probability a ticket sells for $50 is .4. The probability it sells for $100 is .15. The probability it sells for $150 is .2. Find the probability a ticket sells for $200. Find the expected cost (mean cost) of a ticket. Find the standard deviation for the cost of a ticket Find the variance for the cost of a...
To conduct an experiment, a movie theater increased movie ticket prices from $9 to $10 and...
To conduct an experiment, a movie theater increased movie ticket prices from $9 to $10 and measured the change in ticket sales. The theater then gathered data over the following month to determine whether the price increase was profitable. Assume total costs to the theater are the same, whether the price of a ticket is $9 or $10. In order for the ticket price to have been profitable over the month, the elasticity of demand for movie tickets must be...
This is all one question: A theater uses the following table/sheet to manage ticket sales, which...
This is all one question: A theater uses the following table/sheet to manage ticket sales, which turned out to be a very bad practice. The manager of theater hires you to design a database to manage the ticket sale information.    TICKET-SALES (InvoiceNumber, CustomerID, ShowTitle, SeatType, SeatLocation, TicketPrice, CustomerName, CustomerCell, ShowTime, Director_of_Show) Note: A customer can purchase multiple seats in one order (with one InvoiceNumber). It is also the common sense that the price of a ticket/seat depends on the show,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT