1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kirill [66]
3 years ago
7

Write a program in C++ that can be used by a small theater to sell tickets for performances.The theater’s auditorium has 15 rows

of seats with 20 seats in each row.Step 1 The program should have a FUNCTION that displays a screen that shows which seats are available and which are taken. Seats that are taken should be represented by a # symbol and seats that are available should be represented by a * symbol. The first thing your program should do is initialize all of the seats to available (*) and display the seating chart. (HINT: The seating chart should be a two dimensional array.) Here is an example of the seating chart with all seats initialized to availablei causersAdministrator documents\visual studio 201 bug Sample.exe * Seats available # Re served Seats eats: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Row 3 Row 5 nu: 1 Buy ticket Total sel1 and exit Enter your choice 1 Enter row:3 Enter seat 0Step 2 Each row in the auditorium has a different ticket price. So tickets in row 0 may be 5.00 each and tickets in row 1 may be 10.00 each. Your program should have a FUNCTION that reads the ticket price of each row from an input file called prices.txt. The ticket price for each row should be stored in a one dimensional array.The prices txt file contains: you must use the prices.txt file. Use the fstream header.101010888666444222Step 3 Your program should have variables tracking the total number of tickets sold and the total revenue for all tickets sold.Step 4 Your program should allow the user to sell tickets one at a time. The user should be able to sell as many tickets as they would like (you need a loop for this). Do this with some sort of prompt or menu asking the user if they would like to sell another ticket. Don’t forget to validate input data if you need to. To allow the user to sell a ticket your program should have the user enter a row number and a seat number for the ticket they would like to sell. The program should do four things with this information: 1. It should check to see if the seat is available. If the seat is taken the program should not allow the user to sell the ticket. If this happens, print a message to the user saying the ticket is not available and prompt the user to see if they would like to sell another ticket. 2. If the seat is available the program should update the seating chart by putting a taken symbol (#) in that seat’s position in the chart. 3. The program should then look up the row price for the seat sold. Your program should have a variable tracking the total revenue, the price of the seat sold should be added to this total after each sale. 4. Your program should have a variable tracking the total tickets sold. The next thing your program should do when selling a ticket is update the total tickets sold.Step 5 Once the user is finished selling tickets print out an updated seating chart followed by the total tickets sold and the total revenue generate from those tickets. NOTE: You are required to use two arrays in this program, one for the seating chart and one to store the prices for each row. You are also required to use two functions: one to display the seating chart and one to read in the price per row data and store it in the array with the prices for each row in it. You may use other functions if you want to but they are not required.
Engineering
1 answer:
Natalka [10]3 years ago
7 0

Answer:

See explaination

Explanation:

#include<iostream>

using namespace std;

char seating[15][20];

float row_price[15];

//This function will display the seating chart

void display()

{

cout<<"-------------------------- Seating Chart----------------------------\n";

cout<<"Seats: ";

for(int i=0;i<20;i++)

cout<<i<<" ";

cout<<"\n";

for(int i=0;i<15;i++)

{

if(i<10)

cout<<"Row "<<i<<" ";

else

cout<<"Row "<<i<<" ";

for(int j=0;j<20;j++)

{

if(j<10)

cout<<seating[i][j]<<" ";

else

cout<<seating[i][j]<<" ";

}

cout<<"\n";

}

}

//This function will prompt to the user to enter row fares

void row_price_details()

{

cout<<"Enter row wise fares:\n";

for(int i=0;i<15;i++)

cin>>row_price[i];

}

//Main function

int main()

{

char choice;

int i,j,row,seat;

float revenue=0;

//step-1 initializing seating chart with * (available)

for(i=0;i<15;i++)

{

for(j=0;j<20;j++)

{

seating[i][j]='*';

}

}

//displaying seating chart by calling display() function

display();

//prompt the user to enter row fares by calling row_price_details() function

row_price_details();

//Booking seats until user say n or N

do{

cout<<"Enter Row number and Seat number:\n";

cin>>row>>seat;//getting seat and row numbers

//validating enter seat number or row number or with in boundry or not

//if not displays Error message

if(row<15||seat<<20)

{

//checking entered position is available or not

//if not displays sorry message

if(seating[row][seat]=='*')

{

revenue=revenue+row_price[row];//calculating revenue

seating[row][seat]='#';//making seat unavailable

cout<<"Thankyou for Booking\n";

}

//sorry message

else

{

cout<<"The position yor entered is not available\n See seating chart to know available seats\n";

display();

}

}

//Error message

else

{

cout<<"Invalid seat number or row number....\n";

}

cout<<"Do you want to buy another ticket?\nif yes enter Y or y else N or n\n";

cin>>choice;

}while(choice=='Y'||choice=='y');

//displaying summery of the booking

//seating chart and revenue

cout<<"After booking the seating chart:\n";

display();

cout<<"Total Revenue:\n"<<revenue;

}

You might be interested in
Air at 400kPa, 970 K enters a turbine operating at steady state and exits at 100 kPa, 670 K. Heat transfer from the turbine occu
Sonja [21]

Answer:

a

The rate of work developed is \frac{\r W}{\r m}= 300kJ/kg

b

The rate of entropy produced within the turbine is   \frac{\sigma}{\r m}=  0.0861kJ/kg \cdot K

Explanation:

     From  the question we are told

          The rate at which heat is transferred is \frac{\r Q}{\r m } = -  30KJ/kg

the negative sign because the heat is transferred from the turbine

          The specific heat capacity of air is c_p = 1.1KJ/kg \cdot K

          The inlet temperature is  T_1 = 970K

          The outlet temperature is T_2 = 670K

           The pressure at the inlet of the turbine is p_1 = 400 kPa

          The pressure at the exist of the turbine is p_2 = 100kPa

           The temperature at outer surface is T_s = 315K

         The individual gas constant of air  R with a constant value R = 0.287kJ/kg \cdot K

The general equation for the turbine operating at steady state is \

               \r Q - \r W + \r m (h_1 - h_2) = 0

h is the enthalpy of the turbine and it is mathematically represented as          

        h = c_p T

The above equation becomes

             \r Q - \r W + \r m c_p(T_1 - T_2) = 0

              \frac{\r W}{\r m}  = \frac{\r Q}{\r m} + c_p (T_1 -T_2)

Where \r Q is the heat transfer from the turbine

           \r W is the work output from the turbine

            \r m is the mass flow rate of air

             \frac{\r W}{\r m} is the rate of work developed

Substituting values

              \frac{\r W}{\r m} =  (-30)+1.1(970-670)

                   \frac{\r W}{\r m}= 300kJ/kg

The general balance  equation for an entropy rate is represented mathematically as

                       \frac{\r Q}{T_s} + \r m (s_1 -s_2) + \sigma  = 0

          =>          \frac{\sigma}{\r m} = - \frac{\r Q}{\r m T_s} + (s_1 -s_2)

    generally (s_1 -s_2) = \Delta s = c_p\ ln[\frac{T_2}{T_1} ] + R \ ln[\frac{v_2}{v_1} ]

substituting for (s_1 -s_2)

                      \frac{\sigma}{\r m} = \frac{-\r Q}{\r m} * \frac{1}{T_s} +  c_p\ ln[\frac{T_2}{T_1} ] - R \ ln[\frac{p_2}{p_1} ]

                      Where \frac{\sigma}{\r m} is the rate of entropy produced within the turbine

 substituting values

                \frac{\sigma}{\r m} = - (-30) * \frac{1}{315} + 1.1 * ln\frac{670}{970} - 0.287 * ln [\frac{100kPa}{400kPa} ]

                    \frac{\sigma}{\r m}=  0.0861kJ/kg \cdot K

           

 

                   

   

5 0
4 years ago
Given a square matrix [A], write a single line MATLAB command that will create a new matrix [Aug] that consists of the original
Liono4ka [1.6K]

Answer:

Consider A is square matrix of order 4 x 4 generated using magic function. Augmented matrix can be generated using:

Aug=[A eye(size(A))]

Above command is tested in MATLAB command window and is attached in figure below

8 0
3 years ago
Ai r is compressed by a 30-kW compressor from P1 to P2. The air t emperature i s maintained constant at 25oC during thi s proces
RUDIKE [14]

Answer:

The rate of entropy change of the air is -0.10067kW/K

Explanation:

We'll assume the following

1. It is a steady-flow process;

2. The changes in the kinetic energy and the potential energy are negligible;

3. Lastly, the air is an ideal gas

Energy balance will be required to calculate heat loss;

mh1 + W = mh2 + Q where W = Q.

Also note that the rate of entropy change of the air is calculated by calculating the rate of heat transfer and temperature of the air, as follows;

Rate of Entropy Change = -Q/T

Where Q = 30Kw

T = Temperature of air = 25°C = 298K

Rate = -30/298

Rate = -0.100671140939597 KW/K

Rate = -0.10067kW/K

Hence, the rate of entropy change of the air is -0.10067kW/K

3 0
3 years ago
The two windings of transformer is: a)- Conductively linked. b)- Not linked at all. c)- Inductively linked d)- Electrically link
kondor19780726 [428]

The two windings of transformer is c)- Inductively linked

Hope this helped!

4 0
3 years ago
Read 2 more answers
Tech A states that friction brakes lose energy as heat. Tech B states that a brake-by-wire system converts this energy into usef
hjlf
Tech A.......................
4 0
3 years ago
Other questions:
  • Which option is a potential environmental risk of adopting a new technology?
    5·1 answer
  • According to the video, what are examples of systems that Stationary Engineers oversee? Check all that apply. electrical systems
    15·2 answers
  • Route Choice The cost of roadway improvements to the developer is a function of the amount of traffic being generated by the the
    11·1 answer
  • How to Cancel prescription
    12·1 answer
  • It is the same as force. b. Stress that is created by plate collision is the same everywhere and reflects the total force produc
    11·1 answer
  • The annual average of solar photovoltaic energy in Phoenix is 6,720
    8·1 answer
  • Anything you want to do in Hootsuite can be found in the ________, with the main workspace in the _________?
    15·1 answer
  • A driver is traveling at 90 km/h down a 3% grade on good, wet pavement. An accident
    11·1 answer
  • Discuss in detail the following methods used to redistribute income and wealth in cash grants?​
    5·1 answer
  • 7. True or False? The positive effects of a new<br> technology always outweigh its negative effects.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!