Write a cinema reservation program to allow customer to reserve cinema seating.
ID: 3776721 • Letter: W
Question
Write a cinema reservation program to allow customer to reserve cinema seating. At the beginning of the program, ask the customer to input the name and display customize greeting message. Once the seat is reserved, it should be marked as '**'. If customer chooses a seat that has been reserved by other customer, display a message to inform customer and suggest the next available seat. Sample output: Hi, what is your name? Would you like to make next booking (Y or N)?y Notice that reserved seating is marked '**' If seat chosen has been reserved by others, advice next available seatExplanation / Answer
#include<stdio.h>
void display(char s[5][6])
{
int i=0, j=0,c=0;
printf(" ******************************** ");
printf("CINEMA 1 SEATING PLAN ");
printf("******************************** ");
for(i=0;i<5;i++)
{
for(j=0;j<6;j++)
{
if(s[i][j] == '*') {
printf("** ");
c++;
}
else
printf("%d ",c++);
}
printf(" ");
}
}
void main()
{
char seats[30];
char name[100], ch = 'Y';
int i=0, j=0, c = 0, s=0;
for(i=0;i<30;i++)
{
seats[i] = ' ';
}
printf(" Hi, what is your name? ");
scanf("%s",name);
printf("Welcome %s",name);
while(ch == 'Y' || ch == 'y')
{
display(seats);
printf(" Which seat do you want? ");
scanf("%d",&s);
fflush(stdin);
if(seats[s]== ' ')
{
seats[s] = '*';
}
else
{
j = 0;
while(seats[j] != ' ') j++;
printf(" Sorry, seat is taken! Suggest to take seat: %d", j);
}
printf(" Would you like to make next booking ( Y or N ) ? ");
scanf("%c",&ch);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.