Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A movie theater is testing a ticket purchasing system that allows customers to select their seat in the theater at the time of purchase This

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

A movie theater is testing a ticket purchasing system that allows customers to select their seat in the theater at the time of purchase This movie theater has 30 available seats in each theater (numbered 0-29) and once a seat has been selected by one customer, it is marked as booked and cannot be selected by another customer. For the purposes of this simulation, we will assume that patrons are not willing to purchase a ticket if their preferred seat is unavailable, so they will leave without buying a ticket Problem The purpose of this program is to determine whether this seat selection system is efficient. In order to test efficiency, the manager of the theater has set an acceptable success rate to compare the observed success rate against. success rate = of completed transactions (where the desired seat is not already booked) / of attempted transactions If the observed success rate is less than the acceptable success rate, the simulated set of transactions fails to meet the minimum requirements for efficiency. To begin the simulation, the user will input a number of iterations to be evaluated as well as the number of attempted transactions per iteration. Iterations can be thought of as showtimes in a given theater. Each iteration begins with 30 empty seats which can then be booked by customers We will simulate the selection of seats by using the rand0 function to generate random numbers ranging from 0 to 29 corresponding to seats in the theater. In order to use the rand0 function, you must first include stdlib.h and call the srand) function and pass a seed value to it. The seed value will be input by the user. Ex #include int seedval: srand (seedVal): Input The user will input 4 values: The number of iterations/showtimes to be evaluated . The number of transactions attempted for each iteration . The acceptable success rate The user will input 4 values: The number of iterations/showtirmes to be evaluated The number of transactions attempted for each iteration The acceptable success rate . The seed for random number generation You will be expected to validate all four inputs. All four values should be non-negative and the success rate should be between 0 and 1 (inclusive). Iterations must be greater than zero. If one of the four input values is not valid, the output should be Error. Invalid parameters Output Your program should output: The acceptable success rate determined by the user The average attempted sales per iteration The average completed sales per iteration The observed success rate (number of total completed salesumber of total attempted sales) . Whether or not the observed success rate is acceptable Example 7 When input is 10 100 0.5-1 Output is Error. Invalid parameters Example 2 Error. Invalid parameters Example 2 When input is 8 15 0.653 Output is Acceptable success rate: 0.65 Average attempted sales: 15.00 Average completed sales: 12.25 Observed success rate: 0.82 Observed success rate is acceptable Hints: In order to get a float or double from an integer operation, you can typecast as shown below float variableName (Eloat) intvariable1 / intvariable2: . While the total number of seats is a whole number, success rate and averages can have decimal values. You are expected to represent non-integer values to two decimal places. Note: code that does not compile will receve zero points. Submissions will be graded via Zybooks based on 10 test cases (5 visible and 5 hidden) Late submission penalty: * Code submitted within 24 hours after the deadline will receive a 20% penalty Code submitted within 48 hours after the deadline will receive a 40% penalty y 4.16. Homework 2 X C++Shell cpp.sh C++ shell 2include ionanips 3 using narespace std Int in) double succes ate; Add other veriables necessary for your propran cin iterations; umber of iterations to be eveluated can >> nunattepted; /umber of attemptedales cin successitate; cin seed; iseed for random rumber generation r/validsate input /Set seed and start iterations 2 rEvery iteration of the sinulation starts by setting a1l seats to eepty f/coeplete final output: cout "Acceptable success rate; cout ce Averee attenpted sales:c cout "Average completed sales: cout "Observed success rate: -

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions