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
John wants to construct a device using quartz crystal, Which device can he construct?
tatiyna

Answer: Option D, piezoelectric pressure guage

Explanation: Quartz crystal possess a very useful quality in science as they can generate small charges when pressure is applied to them or when they are hit. This property can be harnessed to construct a piezoelectric pressure gauge which would be used to measure and indicate changes in pressure, the quartz crystal releases little voltage each time there is an applied pressure . This device would be able to sense changes in pressure as there would voltage proportional to the applied pressure.

4 0
3 years ago
Read 2 more answers
Fluid power is a. The technology that deals with the generation, control, and transmission of power-using pressurized fluids b.
snow_tiger [21]

Answer:  a) The technology that deals with the generation, control and transmission of power using pressurized fluids

Explanation: Fluid power is defined as the fluids which are under pressure and then are used for generation,control and transmit the power. Fluid power systems produces high forces as well as power in small amount . These systems usually tend to have better life if maintained properly. The force that are applied on this system can be monitored by gauges as well as meter.

8 0
3 years ago
A piston-cylinder device contains 0.1 m3 of liquid water and 0.9 m² of water vapor in equilibrium at 800 kPa. Heat is transferre
docker41 [41]

Answer:

Initial temperature = 170. 414 °C

Total mass = 94.478 Kg

Final volumen = 33.1181 m^3

Diagram  = see picture.

Explanation:

We can consider this system as a close system, because there is not information about any output or input of water, so the mass in the system is constant.  

The information tells us that the system is in equilibrium with two phases: liquid and steam. When a system is a two phases region (equilibrium) the temperature and pressure keep constant until the change is completed (either condensation or evaporation). Since we know that we are in a two-phase region and we know the pressure of the system, we can check the thermodynamics tables to know the temperature, because there is a unique temperature in which with this pressure (800 kPa) the system can be in two-phases region (reach the equilibrium condition).  

For water in equilibrium at 800 kPa the temperature of saturation is 170.414 °C which is the initial temperature of the system.  

to calculate the total mass of the system, we need to estimate the mass of steam and liquid water and add them. To get these values we use the specific volume for both, liquid and steam for the initial condition. We can get them from the thermodynamics tables.

For the condition of 800 kPa and 170.414 °C using the thermodynamics tables we get:

Vg (Specific Volume of Saturated Steam) = 0.240328 m^3/kg

Vf (Specific Volume of Saturated Liquid) = 0.00111479 m^3/kg

if you divide the volume of liquid and steam provided in the statement by the specific volume of saturated liquid and steam, we can obtain the value of mass of vapor and liquid in the system.

Steam mass = *0.9 m^3 / 0.240328 m^3/kg = 3.74488 Kg

Liquid mass = 0.1 m^3 /0.00111479 m^3/kg = 89.70299 Kg  

Total mass of the system = 3.74488 Kg + 89.70299 Kg = 93,4478 Kg

If we keep the pressure constant increasing the temperature the system will experience a phase-change (see the diagram) going from two-phase region to superheated steam. When we check for properties for the condition of P= 800 kPa and T= 350°C we see that is in the region of superheated steam, so we don’t have liquid water in this condition.  

If we want to get the final volume of the water (steam) in the system, we need to get the specific volume for this condition from the thermodynamics tables.  

Specific Volume of Superheated Steam at 800 kPa and 350°C = 0.354411 m^3/kg

We already know that this a close system so the mass in it keeps constant during the process.

 

If we multiply the mass of the system by the specific volume in the final condition, we can get the final volume for the system.  

Final volume = 93.4478 Kg * 0.354411 m^3/kg = 33.1189 m^3

You can the P-v diagram for this system in the picture.  

For the initial condition you can calculate the quality of the steam (measure of the proportion of steam on the mixture) to see how far the point is from for the condition on all the mix is steam. Is a value between 0 and 1, where 0 is saturated liquid and 1 is saturated steam.  

Quality of steam = mass of steam / total mass of the system

Quality of steam = 3.74488 Kg /93.4478 Kg = 0,040 this value is usually present as a percentage so is 4%.  

Since this a low value we can say that we are very close the saturated liquid point in the diagram.  

6 0
4 years ago
Wattage is:
Ksju [112]

Answer:

c.Both A and B.

Explanation:

the wattage is c and d

7 0
3 years ago
An ideal Rankine cycle operates with turbine inlet steam at 90 bar and 500°C, and a condenser at 40 °C. Calculate the efficiency
lilavasa [31]

Answer:

40.8%

Explanation:

A rankine cycle is a generation cycle using water as a working fluid, when heat enters the boiler the water undergoes a series of changes in state and energy until generating power through the turbine.

This cycle is composed of four main components, the boiler, the pump, the turbine and the condenser as shown in the attached image

To solve any problem regarding the rankine cycle, enthalpies in all states must be calculated using the thermodynamic tables and taking into account the following.

• The pressure of state 1 and 4 are equal

• The pressure of state 2 and 3 are equal

• State 1 is superheated steam

• State 2 is in saturation state

• State 3 is saturated liquid at the lowest pressure

• State 4 is equal to state 3 because the work of the pump is negligible.

Once all enthalpies are found, the following equations are used using the first law of thermodynamics

Wout = m (h1-h2)

Qin = m (h1-h4)

Win = m (h4-h3)

Qout = m (h2-h1)

The efficiency is calculated as the power obtained on the heat that enters

Efficiency = Wout / Qin

Efficiency = (h1-h2) / (h1-h4)

first we calculate the enthalpies in all states

h1=3386kJ/Kg

h2=2073kJ/Kg

h2=h3=167.5kJ/Kg

we use the efficiency ecuation

Efficiency =\frac{(h1-h2) }{(h1-h4)}  =\frac{3386-2073}{3386-167.5} =0.408=40.8%

8 0
3 years ago
Other questions:
  • Radioactive wastes are temporarily stored in a spherical container, the center of which is buried a distance of 10 m below the e
    6·1 answer
  • To 3 significant digits, what is the change of entropy of air in kJ/kgk if the pressure is decreased from 400 to 300 kPa and the
    15·1 answer
  • Estimate the daily carbon utilization to remove chlorobenzene from 1.0 MGD of ground water saturated with chlorobenzene. Assume
    12·1 answer
  • a) Give a brief description of the type of DC motor that operates with its field windings running in Series with the armature an
    10·1 answer
  • You're running an engine and seeing that it is exhausting blue smoke. Which is likely to
    9·1 answer
  • A PMMA plate with a 25 mm (width) x 6.5 mm (thickness) cross-section has a contained crack of length 2c = 0.5 mm in the center o
    10·1 answer
  • Liquid benzene and liquid n-hexane are blended to form a stream flowing at a rate of 1700 lbm/h. An on-line densitometer (an ins
    6·1 answer
  • For the following circuit diagram, if A=010 , B= 101.
    6·1 answer
  • PLEASE HELP QUICK!!
    6·1 answer
  • The source term will affect all algebraic equations.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!