Write a program in c that does the following First make a da

Write a program in c++ that does the following:

First make a data file prices.dat with for the movie theatre program:

10

10

10

9

9

9

8

8

8

7

7

7

6

6

6

Program #2-Movie Theater Tickets Write a program 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 available. Seats: 01 2 3 4 5 6 78 9 1011 12 13 14 15 16 17 18 19 Step 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.dat. The ticket price for each row should be stored in a one dimensional array.

Solution

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

char seats[15][20];
int ticketscount=0, revenue=0;
int price[15];


bool displaySeats(int row,int seat);
int main()
{
   int choice;
   int row=-1;
   int seat=-1;
   char ch;
   int cost;
   bool boolean=1;
//defines an input stream for the data file  
ifstream dataIn;
  
//Opening the input file
dataIn.open(\"D:\\\\prices.dat\");
for(int i=0;i<15;i++)
{
   dataIn>>cost;
   price[i]=cost;
}
  
   //This Logic will Sort the Array of elements in Ascending order
   int temp;
   for (int i = 0; i < 15; i++)
{
for (int j = i + 1; j < 15; j++)
{
if (price[i] > price[j])
{
temp = price[i];
price[i] = price[j];
price[j] = temp;
}
}
}

displaySeats(row,seat);
  
do
{
cout<<\"Menu:\"<<endl;
cout<<\"1) Buy Ticket\"<<endl;
cout<<\"2) Total Sell Ticket\"<<endl;
cout<<\"Enter Your choice :\";
cin>>choice;
switch(choice)
{
    case 1:{
        while(true)
        {
        cout<<\"Enter Row :\";
cin>>row;
cout<<\"Enter seat :\";
cin>>seat;
boolean=displaySeats(row,seat);
if(boolean)
{
cout<<\":: Seat not available ::\"<<endl;  
continue;
       }
cout<<\"\ Do you Want to Book Another Seat(Y/N):\";
       cin>>ch;

       if(ch==\'y\'||ch==\'Y\')
       {
       continue;
       }else
       {
       break;
       }
       }
       
       break;
   }
        case 2:
       {   
       cout<<\"Total Tickets sold :\"<<ticketscount<<endl;
       cout<<\"Total Revenue :\"<<revenue<<endl;
       break;
       }
}


}while(choice!=2);
  
  
   return 0;
}
bool displaySeats(int row,int seat)
{
   int val=0;
   if(row=-1 && seat==-1)
   {
       for(int i=0;i<15;i++)
   {
       for(int j=0;j<20;j++)
       {
           seats[i][j]=\'*\';
       }
   }

   }
   else
   {
       for(int i=0;i<15;i++)
   {
       for(int j=0;j<20;j++)
       {
           //cout<<row<<endl;
      
           if(seats[row][seat]==\'*\')
           {
       seats[row][seat]=\'#\';
           ticketscount++;
           revenue+=price[row];
           val=1;
           }
           else
           {
           val=0;  
          
           }
          
       }
   }

   }
      
   cout<<\"Seats 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\"<<endl;
  
   for(int i=0;i<15;i++)
   {
       if(i<10)
       cout<<\"Row 0\"<<i<<\" \";
       else  
       cout<<\"Row \"<<i<<\" \";
       for(int j=0;j<20;j++)
       {
           if(j<10)
           cout<<setw(2)<<seats[i][j]<<\" \";
           else
           cout<<\" \"<<seats[i][j]<<\" \";
       }
      
       cout<<\"\ \ \";
   }
   return val;
}

Write a program in c++ that does the following: First make a data file prices.dat with for the movie theatre program: 10 10 10 9 9 9 8 8 8 7 7 7 6 6 6 Program #
Write a program in c++ that does the following: First make a data file prices.dat with for the movie theatre program: 10 10 10 9 9 9 8 8 8 7 7 7 6 6 6 Program #
Write a program in c++ that does the following: First make a data file prices.dat with for the movie theatre program: 10 10 10 9 9 9 8 8 8 7 7 7 6 6 6 Program #
Write a program in c++ that does the following: First make a data file prices.dat with for the movie theatre program: 10 10 10 9 9 9 8 8 8 7 7 7 6 6 6 Program #

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site