Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A small theatre wants a new reservation system for ticketing. The application sh

ID: 3562586 • Letter: A

Question

A small theatre wants a new reservation system for ticketing.

The application should display the following alternatives: Please type 1 for Box Seats, Please type 2 for Front Row Seating and Please type 3 for other Floor Seating. If the user types 1, your app should assign a seat in seats 18. If the user types 2, your app should assign a seat in seats 9-28.   If the user types 3, your app should assign a seat in seats 29-58.

Use a one-dimensional array of type bool to represent the seating chart of the theatre. Initialize all the elements of the array to false to indicate that all the seats are empty. As each seat is assigned, set the corresponding element of the array to true to indicate that the seat is no longer available.

Your app should never assign a seat that has already been assigned. If the particular section is full, your app should advise that it is full and ask for another selection.

PLEASE explain so I can understand why and how the code works.

Explanation / Answer

here is how code works

- declared an array as you suggested

- used a do while loop to run the process. loop ends when all the seats are filled

- take input from user using scanner.

- used a function fillseat to fill appropriate seat acc. to the parameter passed if other than 1,2,3 is passed then message is displayed no seat allocated

- after each input seat matrix is displayed to the user 0 indicates empty seat and 1 indicates filled seat

C# Code

using System;

namespace ConsoleAppC
{
class theatre {
    static int count=58;
    static bool[] seats=new bool[count];
    static void Main(string[] args)
    {
        for(int i=0;i<count;i++)
            seats[i]=false;
    
        do
        {
        Console.WriteLine("Please type 1 for Box Seats Please type 2 for Front Row Seating Please type 3 for other Floor Seating");
      
        if(fillseat(Convert.ToInt32(Console.ReadLine())) == false)
            Console.WriteLine("No seat can be alloted in this category kindly retry");
        Console.WriteLine("Seat status");
        for(int i=0;i<count;i++)
        {
            Console.Write((i+1) +":"+ ((seats[i])?"1":"0") +",");
        }
        Console.WriteLine();
        }while(checkemptyseat());
    }
    private static bool fillseat(int option)
    {
        int low=0,high=0;
        if(option==1)
        {
            low=1;
            high=8;
        }
        else if(option==2)
        {
            low=9;
            high=28;
        }
        else if(option==3)
        {
            low=29;
            high=58;
        }
        else
            return false;
    
        for(int i=low-1;i<high;i++)
        {
            if(seats[i]==false)
            {
                seats[i]=true;
                return true;
            }
        }
        return false;
    }
    private static bool checkemptyseat()
    {
        for(int i=0;i<count;i++)
        {
            if(seats[i]==false)
                return true;
        }
        return false;
    }

}

}

Output:

Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
Seat status
1:1,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
Seat status
1:1,2:1,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
Seat status
1:1,2:1,3:1,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
Seat status
1:1,2:1,3:1,4:1,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
Seat status
1:1,2:1,3:1,4:1,5:1,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
No seat can be alloted in this category kindly retry
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
No seat can be alloted in this category kindly retry
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
No seat can be alloted in this category kindly retry
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
No seat can be alloted in this category kindly retry
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
No seat can be alloted in this category kindly retry
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
1
No seat can be alloted in this category kindly retry
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
3
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:1,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
2
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:1,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
2
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,10:1,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:1,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
3
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,10:1,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:1,30:1,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating
3
Seat status
1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,10:1,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:1,30:1,31:1,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,
Please type 1 for Box Seats
Please type 2 for Front Row Seating
Please type 3 for other Floor Seating

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote