Design an algorithm to assign costs to seats.

Assignment Help C/C++ Programming
Reference no: EM13936769

Implement a simple seat reservation system for a theater in C++. The seats in the theater will be represented with a two dimensional array. The closer the seats are to the stage, the more expensive the seats are. Moreover, within a row, the seats at the center shall be more expensive.

Use a simple algorithm to assign costs to seats. The seats in one row cost $10 more than the seats in the previous row. Within a row of n seats, the first and last n/4 seats should be $5 cheaper than the rest of the seats.

The following charts are examples of the expected costs of seats:

40 45 45 40
30 35 35 30
20 25 25 20
10 15 15 10

To do so, create a class TheaterReservationSystem having the following members:

A constructor taking two int constants: rows and seatsPerRow.

A function member int computeCost(int row, int seat). This function will calculate the cost of the seat based on the row and seat number as described above.

A function member bool reserveSeat(int cost). This function will reserve the first available seat of the specified cost if there is one. If the program finds a seat of the specified cost, the function shall return true. Otherwise, the function shall return false.

A function member bool reserveBestSeat(int lowestCost, int highestCost). This function will reserve the best seat available within the specified cost range. One seat is considered better than another if either it is closer to the stage or it is in the same row but in the center of the row.

A function member void displaySeatsCost(). This function will print to the standard output a matrix containing the cost of the seats.

A function member void displaySeats(). This function will print to the standard output a matrix showing which seats are reserved and which seats are not.

A data member m_seats of type bool[][].

Create a driver file TheaterReservationDriver. In this file create two constants int: seats and seatsPerRow. Upon executing the driver, it will create an object TheaterReservationSystem passing seats and seatsPerRow to its constructor. The program shall display the following menu:

Enter 1 to reserve a seat

Enter 2 to reserve the best seat available

Enter 3 to display seats cost

Enter 4 to display reservations

Option 1 will prompt the user for a cost and it will invoke function reserveSeat. Option 2 will prompt the user for a cost range and it will invoke function reserveBestSeat. These two options shall display an appropriate message indicating whether the reservation could be made or not. Options 3 and 4 will invoke displaySeatCost and displaySeats respectively.

Reference no: EM13936769

Questions Cloud

Very important component of your system : The user interface is a very important component of your system. In this assignment you are first asked to read and understand a popular set of usability heuristics. Readings (Jakob Nielsen is a very renowned usability expert):
What proportion of the population are carriers : Imagine a population of 10,000 humans living on an isolated island. Every generation, an average of one individual is born with cystic fibrosis, a fatal genetic disease caused by a recessive allele, What are the frequencies of the dominant, and rec..
Introductory background to the yeppoon show : 1. Give an introductory background to the Yeppoon show. 2. Conduct a literature review of about 600 words about customer satisfaction, in particular at shows.
Strategic agility in the context of uk financial service : A research on Strategic Agility in the context of UK Financial Services Industry. Define strategic agility. Assessing the current levels of strategic agility. Are there any internal or external barriers to agility.
Design an algorithm to assign costs to seats. : Implement a simple seat reservation system for a theater in C++. The seats in the theater will be represented with a two dimensional array. The closer the seats are to the stage, the more expensive the seats are. Moreover, within a row, the seats ..
Calculate the economic order quantity for component rb : Calculate the economic order quantity (to the nearest unit) for component RB. Briefly describe the circumstances in which Jane plc should consider having a buffer stock of component RB.
How has the use of recombinant dna technology : How has the use of recombinant DNA technology added to the treatment of the disorder? How has the treatment affected the long-term quality of life and long-term outlook of people with the disorder?
Contemporary internal information system : You should complete the following tasks for the given business scenario. You are one of a team of newly graduated software engineers working on a project to build the infrastructure of an organization with an intensive and data sensitive internal ..
Annual show in yeppoon for the show holiday : The Yeppoon and District Show Society Inc organizes an annual show in Yeppoon for the Show Holiday. This year it was organized on the 6th and 7th June 2015 and attracted over 10000 people.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Q1 write a program that generates the following

q1. write a program that generates the following outputnbspnbspnbspnbspnbspnbspnbspnbsp 10nbspnbspnbspnbspnbspnbspnbsp

  Implement an overloaded addition operator for point class

Implement overloaded addition operator + and subtraction operator - for the Point class. Implement an overloaded multiplication operator * to return the dot product of two Point objects.

  Write a driver program called testrationalnumber.cpp

Write a driver program called testRationalNumber.cpp to test each of the above functions and overloaded operators in the RationalNumber class.

  Er diagram to the corresponding tables

Chen, the Customer Analyst of Shopping Spree, has to make the ER diagram to represent the preceding situation, and then to map the ER diagram to the corresponding tables. Help Chen to do the same.

  Prompts the user to enter an integer

Write the code that prompts the user to enter an integer between 1 and 20 (including 1 and 20), reads the value using cin, and then prints the value that they entered in a statement that begins with "You entered a ". Save this version in a separate l..

  Store user input - write c++ program

Write C++ program to provide the following functionality - Ask users to enter 10 integer numbers.

  Write an abstract class carbon footprint

Using an abstract class with only pure virtual functions, create three small classes unrelated by inheritance---clases Building, Car and Bicycle.

  Discuss the differences concerning how a program would acces

Discuss the differences concerning how a program would access the members of objects that have been declared as an array of objects

  Need to prepare a c++ program of class swap

Class Swap contains tow data members num1 , num2 and member function swapping ,the aim of this function is swapping num1 and num2 values , swapping should done by using pointer , i.e. if num1= 20 and num2 =5 they become : num1= 5 and num2=20.

  Write a program that prints minimax and maximin of a matrix

The optimal strategies are possible when these two values are equal. Write a program that prints the minimax and the maximin of a given matrix.

  Write short c program to develops two processes

Write down a short C program which develops two processes. Each process must repeatedly write its own unique message to test file, one character at time. Do you see garbled messages in the file? Explain why or why not?

  Write a program that converts between app and ppm values

Write a simple program that converts between APP and PPM values

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd