please help me
Program Plan:
• Create a C ++ file called with word Seats.cpp
• Write header files at the header section.
• Start main method declaration.
• Declare and initialize variables for ROWS=20
• SEATS in each row, SEATS=40
• Set cost of ticket, COST=7.50
• Set total cost =0, totalCost=0
• Calculate total seats in auditorium, totalSeats=ROWS*SEATS
• Set occupied=0
• set sentinel =999
• Declare an array of type int gallary[ROWS][SEATS]
• Declare two integer variables, seatRow and seatNumber
• Read row number and seat number from user and check if the seat is already occupied.
• Re-prompt user to enter until user enters 999 for seat row and seat number to stop reading.
• Then print the number of seats occupied and number of seats left.
Program Code
/********************************************************
* The C ++ program that prompts user to enter row *
* number and seat number. Then the program print *
* if the seat is already reserved or not. If the seat *
* is reserved then print an message and prompt to select*
* another seat. The program prints the cost of seat and*
* continues to prompt until user enters a sentinel *
* vlaue,999 to stop reading . Then the program prints *
* total seats occupied and empty seats left in auditorium.
*********************************************************/
//Seats.cpp
//header file
#include
using namespace std;
int main()
{
//declare variables for ROWS
const int ROWS=20;
//SEATS in each row
const int SEATS=40;
//Set cost of ticket
const float COST=7.50;
//Set total cost =0
float totalCost=0;
//Calculate total seats in auditorium
int totalSeats=ROWS*SEATS;
//Set occupied=0
int occupied=0;
//set sentinal =999
int sentinal=999;
//declare an array of type int
int gallary[ROWS][SEATS];
/*declare two integer variables, seatRow and
seatNumber */
int seatRow;
int seatNumber;
//Set all seats to 0 means all seats are empty
for(int row=0;row
for(int seat=0;seat
gallary[row][seat]=0;
//print a welcome message
cout<<"***Welcome to O'Neil High School
Arts Auditorium***"<
cout<
/*do-while loop continues to prompt until user enters
999 to stop reading seat numbers*/
do
{
/*do-while loop that prompt until the user enters
valid seat row or enters a sentinel value call
break to come out of loop. */
do
{
cout<<"Enter row number : ";
cin>>seatRow;
if(seatRow==sentinal)
break;
if(seatRow<0 || seatRow>20)
cout<<
"Invalid row number.Enter valid row number 1-20. "
<
}while(seatRow<0 || seatRow>20);
/* do-while loop that prompt until the user enters valid
seat number or enters a sentinal value call break to
come out of loop */
do
{
cout<<"Enter seat number : ";
cin>>seatNumber;
if(seatNumber==sentinal)
break;
if(seatNumber<0 || seatNumber>40)
cout<<"Invalid seat number.Enter valid
row number 1-40. "<
}while(seatNumber<0 || seatNumber>40);
//call break to stop reading user input
if(seatRow==sentinal && seatNumber==sentinal)
break;
//check if the seat is occupied or not
else if(gallary[seatRow][seatNumber]==1)
cout<<"The seat number ["
<
<<"] is already occupied ."<
else
{
/*otherwise set 1 to seat number that
indicates the seat is occupied */
gallary[seatRow][seatNumber]=1;
//add COST to total cost
totalCost+=COST;
//increment the occupied by one
occupied++;
}
//print totalCost
cout<<"Total Cost : $"<
}while(seatRow!=sentinal && seatNumber!=sentinal);
/*print number of seat occupied and number of seats
left empty*/
cout<
<
cout<<"Empty seats : "<<(totalSeats-occupied)<
system("pause");
return 0;
}
Sample output:
Sample run1:
***Welcome to O'Neil High School Arts Auditorium***
Enter row number : 1
Enter seat number : 1
Total Cost : $7.5
Enter row number : 1
Enter seat number : 2
Total Cost : $15
Enter row number : 1
Enter seat number : 3
Total Cost : $22.5
Enter row number : 1
Enter seat number : 1
The seat number [1,1] is already occupied .
Total Cost : $22.5
Enter row number : 999
Enter seat number : 999
Number of seats reserved : 3
Empty seats : 797
Sample run2:
***Welcome to O'Neil High School Arts Auditorium***
Enter row number : 1
Enter seat number : 1
Total Cost : $7.5
Enter row number : 1
Enter seat number : 2
Total Cost : $15
Enter row number : 3
Enter seat number : 1
Total Cost : $22.5
Enter row number : 5
Enter seat number : 6
Total Cost : $30
Enter row number : 999
Enter seat number : 999
Number of seats reserved : 4
Empty seats : 796
The O’Neill High School Performing Arts Center auditorium contains 20 rows (numbered 1 through 20) with 40 seats each (numbered 1 through 40). Write an application that allows a user to continuously enter a row and seat request until a sentinel value is e
Find Bugs in the pseudocode// A high school is holding a recycling competition// This program allows a user to enter a student's // year in school (1 through 4)// and number of cans collected// Data is entered continuously until the user wnats to quit// After headings, output is four lines// one for each school year classstart Declarations num year num cans num SIZE = 4 num QUIT = 9 ...