Question

Using C not C++, Write a program that can be used by a small theater to...

Using C not C++, Write a program that can be used by a small theater to sell tickets for performances. The theater’s auditorium has 15 rows of seats, with 30 seats in each row. The program should display a screen that shows which seats are available and which are taken. For example, the following screen shows a chart depicting each seat in the theater. Seats that are taken are represented by an * symbol, and seats that are available are represented by a # symbol:

Seats 123456789012345678901234567890

Row 1 ***###***###*########*****####

Row 2 ####*************####*******##

Row 3 **###**********########****###

Row 4 **######**************##******

Row 5 ********#####*********########

Row 6 ##############************####

Row 7 #######************###########

Row 8 ************##****############

Row 9 #########*****############****

Row 10 #####*************############

Row 11 #**********#################**

Row 12 #############********########*

Row 13 ###***********########**######

Row 14 ##############################

Row 15 ##############################

Here is a list of tasks this program must perform: • When the program begins, it should ask the user to enter the seat prices for each row. The prices can be stored in a separate array. (Alternatively, the prices may be read from a file.) • Once the prices are entered, the program should display a seating chart similar to the one shown above. The user may enter the row and seat numbers for tickets being sold. Every time a ticket or group of tickets is purchased, the program should display the total ticket prices and update the seating chart. • The program should keep a total of all ticket sales. The user should be given an option of viewing this amount. • The program should also give the user an option to see a list of how many seats have been sold, how many seats are available in each row, and how many seats are available in the entire auditorium. Input Validation: When tickets are being sold, do not accept row or seat numbers that do not exist. When someone requests a particular seat, the program should make sure that seat is available before it is sold.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here, I have following program code as shown below with sample output.

Code:

// declare header file

#include<iostream>

#include<iomanip>

using namespace std;

// define a constant variable

const int ROWS=15;

const int SEATS=30;

// method definitions

void Firstallary(char gallary[][SEATS]);

void Show(char gallary[][SEATS]);

bool isValid(int ,int);

int Selection();

void DisplayPrice(int totalPrice);

void displayStatistics(char gallary[][SEATS],int prices[],int sold[],int totalPrice);

// main function

int main()

{

// declare array variable

   int Cost[ROWS]={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150};

   int sold[ROWS]={0};

   char InGallary[ROWS][SEATS];

// calls the method

Firstallary(InGallary);

// declare required variables

   int rows;

   int seatNo;

   int SoldSeats=0;

   int Totalcost=0;

   char choice='y';

// use loop until the condition

   while(tolower(choice)=='y')

   {

     // make selection

       switch(Selection())

       {

           

           // for case 1

       case 1:

       do

       {

           cout<<"Enter Row Number : ";

           cin>>rows;

           cout<<"Enter Seat Number : ";

           cin>>seatNo;

          // checks

           if(isValid(rows,seatNo))

           {

             // make increments

               sold[rows]++;

               // add

               Totalcost+=Cost[rows-1];

               // assign asterik

               InGallary[rows-1][seatNo-1]='*';

               // calls the method

               Show(InGallary);

           }

           else

               cout<<"Error: Invalid seat number ."<<endl;

       }while((rows<1 ||rows>15) && (seatNo<1 || seatNo>30));

       break;

       case 2:

           // calls the method

           DisplayPrice(Totalcost);

           break;

       case 3:

         // calls the method

           displayStatistics(InGallary,Cost,sold,Totalcost);

           break;

       }

       cout<<"Do you Want to Continue : [y] for yes or [n] for no : ";

       cin>>choice;

   }

   return 0;

}

void displayStatistics(char gallary[][SEATS],int prices[],int sold[],int totPrice)

{

   int Total_Seat=ROWS*SEATS;

   int Total_Seats_Sold=0;

   for(int row=0;row<ROWS;row++)

   {

       Total_Seats_Sold+=sold[row];

   }

   cout<<"\tSeats Sold : "<<Total_Seats_Sold<<endl;

   cout<<"\tSeats Available in each row : "<<endl;

   for(int row=0;row<ROWS;row++)

   {

       cout<<"Row "<<(row+1)<<setw(10)<<SEATS-sold[row]<<endl;

   }

   cout<<"Seats Available in Auditorium : "<<(Total_Seat-Total_Seats_Sold)<<endl;

   cout<<"Total Price of Tickets Sold $"<<totPrice<<endl;

}

void DisplayPrice(int TotalPrices)

{

   cout<<"Total amount of seats sold : $"<<TotalPrices<<endl;

}

int Selection()

{

   int select;

   cout<<"\t***Menu***"<<endl<<endl;

   cout<<"\t1.Select Seats"<<endl;

   cout<<"\t2.Show Total Amount of Sold"<<endl;

   cout<<"\t3.Show Statistics of Sold Tickets "<<endl;

   cout<<"Enter your Choice : ";

   cin>>select;

   return select;

}

bool isValid(int rowNo,int seatNo)

{

   return (rowNo>=1 && rowNo<=15) && (seatNo>=1 || seatNo<=30);

}

void Firstallary(char Gallary[][SEATS])

{

   for(int row=0;row<ROWS;row++)

   {

       for(int s=0;s<SEATS;s++)

           Gallary[row][s]='#';

   }

}

void Show(char gallary[][SEATS])

{

   cout<<"\t Example "<<endl;

   cout<<"\tSeats"<<endl;

   cout<<setw(10);

   for(int se=1;se<=3;se++)

   {

       for(int n=1;n<=9;n++)

           cout<<n;

       cout<<"0";

   }

   cout<<endl;

   for(int r=0;r<ROWS;r++)

   {     

       if((r+1)<10)

           cout<<left<<setw(4)<<"Rows"<<left<<(r+1)<<right<<setw(5);     

       else

           cout<<left<<setw(4)<<"Rows"<<left<<(r+1)<<right<<setw(4);     

       for(int s=0;s<SEATS;s++)

           cout<<gallary[r][s];

       cout<<endl;

   }

}

Add a comment
Know the answer?
Add Answer to:
Using C not C++, Write a program that can be used by a small theater to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can you help us!! Thank you! C++ Write a program that can be used by a...

    Can you help us!! Thank you! C++ Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...

  • Write a program in C to assign seats of a movie theater (capacity: 200 seats). Your...

    Write a program in C to assign seats of a movie theater (capacity: 200 seats). Your program should display the following menu of alternatives: Please type 1 for "section A, $50/ticket" type 2 for "section B, $70/ticket", and type 3 for "section C, $80/ticket".  If the user types 1, then your program should assign a seat in the A section (seats 1–50). If the user types 2, then your program should assign a seat in the B section (seats 51–100). If...

  • Your assignment is to design a TicketManager class that can keep track of the number of...

    Your assignment is to design a TicketManager class that can keep track of the number of seats available in a theater’s auditorium. The TicketManager class should have a two-Dimensional array, which has 15 rows and 30 columns for all the seats available in the auditorium, also an array of double to keep track of the price of tickets for each row. Each row has a different price. Use the following UML diagram to design the class: -------------------------------------------------------------------- + NUMROWS :...

  • P7.5– A theater seating chart is implemented as a two-dimensional array of ticket prices, like this:...

    P7.5– A theater seating chart is implemented 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...

  • The language is C++ for visual studio express 2013 for windows create a TicketManager class and...

    The language is C++ for visual studio express 2013 for windows create a TicketManager class and a program that uses the class to sell tickets for a performance at a theater. Here are all the specs. This is an intense program, please follow all instructions carefully. -I am only creating the client program that uses the class and all it's functions -The client program is a menu-driven program that provides the user with box office options for a theater and...

  • In C++. Write a program that can be used to assign seats for a commercial airplane...

    In C++. Write a program that can be used to assign seats for a commercial airplane and print out the ticket total. The airplane has 13 rows, with row 7 being the Emergency Exit row. Each row has 7 seats, there are two seats on each side of the plane and three seats in the middle with aisles on both sides. Rows 1 and 2 are considered first class with tickets for this specific  flight being $872.00 round trip. Rows 3...

  • Write pseudocode for a program where the seating map for a particular performance at a theater...

    Write pseudocode for a program where the seating map for a particular performance at a theater contains 70 rows of 100 seats each. Using an array where applicable, develop the pseudeocode for a program that allows a user to continuously enter each household size and then a) Allows a user to continuously enter a row number and seat number until they enter an appropriate sentinel value for the row number in order to stop entering input. Each time the user...

  • C++ exercise: Theater Seating Revenue with Input Validation A dramatic theater has three seating sections, and...

    C++ exercise: Theater Seating Revenue with Input Validation A dramatic theater has three seating sections, and it charges the following prices for tickets in each section: section A seats cost $20 each, section B seats cost $15 each, and section C seats cost $10 each. The theater has 300 seats in section A, 500 seats in section B, and 200 seats in section C. Design a program that asks for the number of tickets sold in each section and then...

  • The Course Project can be started in Week 7 and is due by 11:59 pm CT...

    The Course Project can be started in Week 7 and is due by 11:59 pm CT Saturday of Week 8. It must follow standard code formatting and have a comment block at the top of the code file with a detailed description of what the program does. Functions must have a comment block with a detailed description of what it does. Pseudocode must be provided in the comment block at the top of the file. This program will allow the...

  • For c++ Write a program that can be used to assign seats for a commercial airplane....

    For c++ Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business class, and rows 8 rows through 13 are economy class. Your program must prompt the user to enter the following information: Ticket type (first class, business class, or economy class) Desired seat a. b. Output the seating plan in the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT