Question
Can you help us!! Thank you!

Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen tha
When the user selects the request tick user selects the request tickets menu option, the program nber of seats the patron wan
#include<iostream> #include<fstream> using namespace std; const int COLS - 30; const int ROWS - 15; void displaySesting(char[
rowPrices[1] - rowBasePrice + rowBasePrice (rowPriceMultiplier 1)) Ifstrean 1File; 1File.open(SeatAvailability.txt); if (1F

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

#include <iostream>
#include <fstream>
using namespace std;

const int COLS = 30;
const int ROWS = 15;

void displaySeating(char[][COLS], const int);
double getRowPrice(int);
void requestTickets(char[][COLS], const int);
void getSalesReport(char[][COLS], const int, const double);
void updateSeating(char[][COLS], const int);

int main()
{
char seating[ROWS][COLS];

ifstream iFile;
iFile.open("SeatAvailability.txt");
if(iFile.fail())
{
cout<<"\n There is no file called: SeatAvailability.txt in the source file\n";
}
else
{
int j;
char ch;
for(int i = 0; i < ROWS; i++)
for(j = 0; j < COLS; j++)
iFile>>seating[i][j];
}
iFile.close();
displaySeating(seating, ROWS);
requestTickets(seating, 4);
displaySeating(seating, ROWS);
}
void displaySeating(char seating[][COLS], const int row)
{
cout<<"\n\n ************************** Seating Chart **************************";
cout<<"\n 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0\n";
for(int r = 0; r < ROWS; r++)
{
for(int c = 0; c < COLS; c++)
cout<<" "<<seating[r][c];
cout<<endl;
}
}

double getRowPrice(int row)
{
double rowPrices[ROWS];

double rowBasePrice = 10.0;
double rowPriceMultipler = 0.05;

for(int i = 0; i < ROWS; i++)
rowPrices[i] = rowBasePrice + (rowBasePrice * (rowPriceMultipler * i));

return rowPrices[row];
}

void requestTickets(char seating[][COLS], const int numberOfSeats)
{
int availableSeats, row;
double rowPrice, price;
for(int r = 0; r < ROWS; r++)
{
availableSeats = 0;
for(int c = 0; c < COLS; c++)
if(seating[r][c] == '#')
availableSeats++;
if(availableSeats >= numberOfSeats)
{
row = r;
break;
}
}

if(availableSeats < numberOfSeats)
cout<<numberOfSeats<<" not available.";
else
{
updateSeating(seating, numberOfSeats);
rowPrice = getRowPrice(row);
price = (numberOfSeats * rowPrice);
cout<<"\n Number of seats sold: "<<numberOfSeats;
cout<<"\n Price per the seat for row "<<row + 1<<" = "<<rowPrice;
cout<<"\n Total price = "<<price;
getSalesReport(seating, numberOfSeats, price);
}
}
void updateSeating(char seating[][COLS], const int numberOfSeats)
{
int current = 0;
for(int r = 0; r < ROWS; r++)
{
for(int c = 0; c < COLS; c++)
{
if(seating[r][c] == '#' && current < numberOfSeats)
{
seating[r][c] = '*';
current++;
}
}
}
}

void getSalesReport(char seating[][COLS], const int numberOfSeats, double price)
{
int available = 0, sold = 0;
for(int r = 0; r < ROWS; r++)
{
for(int c = 0; c < COLS; c++)
{
if(seating[r][c] == '#')
available++;
else
sold++;
}
}
cout<<"\n\n ********************** Sales Report **********************";
cout<<"\n Seats available: "<<available<<"\n Sold: "<<sold;
cout<<"\n You have purchased: "<<numberOfSeats;
cout<<"\n You need to pay: $"<<price;
}

Sample Output:

************************** Seating Chart **************************
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Number of seats sold: 4
Price per the seat for row 1 = 10
Total price = 40

********************** Sales Report **********************
Seats available: 446
Sold: 4
You have purchased: 4
You need to pay: $40

************************** Seating Chart **************************
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
* * * * # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Add a comment
Know the answer?
Add Answer to:
Can you help us!! Thank you! C++ Write a program that can be used by a...
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
  • 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 :...

  • 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...

  • Program is in C++, program is called airplane reservation. It is suppose to display a screen...

    Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...

  • 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...

  • 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...

  • 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...

  • I have to write a C program to assign seats on each flight of the airline’s...

    I have to write a C program to assign seats on each flight of the airline’s only plane (capacity: 40 seats, in 10 rows). For the sake of simplicity, assume that each row has 4 seats labeled A, B, C, D. Your program should display the following menu of alternatives: Please type 1 for "first class" Please type 2 for "business class" Please type 3 for “economy class”. If the person types 1, then your program should assign a seat...

  • Hi I need help with a java program that I need to create a Airline Reservation...

    Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...

  • 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...

  • 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...

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
ADVERTISEMENT