Skip to main content

The Fundamentals of Digital Marketing Certification

The Fundamentals of Digital Marketing Certification
Trying to make use of some spare time during these endless lockdowns. I completed The Fundamentals of Digital Marketing course on Google Digital Garage and got certified. This is not a great victory, nevertheless, I celebrate every small step towards a greater goal. #googlegarage #fundamentalsofdigitalmarketing #digitalmarketing

FDS 7

 Practical No: -7

Experiment No. 7: The ticket booking system of Cinemax theatre has to be implemented using C++

program. There are 10 rows and 7 seats in each row. Doubly circular linked list has to be maintained

to keep track of free seats at rows. Assume some random booking to start with. Use array to store

pointers (Head pointer) to each row. On demand

a) The list of available seats is to be displayed

b) The seats are to be booked.

c) The booking can be cancelled.

Code:

#include<iostream>

using namespace std;

class mynode

{

 public:

 char book_stats;

 mynode *prev,*next;

};

class thetr_cinemax

{

 public:

 mynode *head,*last;

 //member functions

 void create();

 void show();

 void book_tkt();

 void cancel_tkt();

 thetr_cinemax()

 {

 head=NULL;

 }

};

void thetr_cinemax::create() //function to create arrangement.

 {

 mynode *n;


 for(int i=0;i<=7;i++)

 {

 n=new mynode;

 n->book_stats=NULL;

 n->prev=NULL;

 if(head==NULL)

 {

 head=n;

 n->next=head;

 }

 else

 {

 mynode *t1,*t2;

 t1=head;

 while(t1->next!=head)

 {

 t2=t1;

 t1=t1->next;

 }


 t1->next=n;

 n->prev=t1;

 n->next=head;

 t1->prev=t2;

 }

 }

 }


 void thetr_cinemax::show()

 {

 mynode *temp;

 temp=head;

 while(temp->next!=head)

 {

 cout<<"("<<temp->book_stats<<")"<<"\t";

 temp=temp->next;

 }

 }


 void thetr_cinemax::book_tkt()

 {

 mynode *temp;

 int row1,i;

 cout<<"Enter seat number you want to book:";

 cin>>row1;


 temp=head;

 for(i=1;i<row1;i++)

 {

 temp=temp->next;

 }


 if(temp->book_stats=='B')

 {

 cout<<"\n Selected seat is not available!!!\n";

 }


 else

 {

 temp->book_stats='B';

 }

 }


 void thetr_cinemax::cancel_tkt()

 {

 mynode *temp;

 int row1,i;

 cout<<"Enter seat number you want to cancel:";

 cin>>row1;


 temp=head;

 for(i=1;i<row1;i++)

 {

 temp=temp->next;

 }


 if(temp->book_stats==NULL)

 {

 cout<<"\n The selected seat is free.\n\n";

 }


 else

 {

 temp->book_stats=NULL;

 }

 }


 int main()

 {

 int row,j=1,choice;

 char ans;


 thetr_cinemax c[10];

 for(int i=1;i<10;i++)

 {

 c[i].create();

 }


 for(int a=0;a<7;a++)

 {

 cout<<"\t"<<j;

 ++j;

 }


 cout<<endl;

 j=1;


 for(int i=1;i<10;i++)

 {

 cout<<j<<"\t";

 c[i].show();

 cout<<endl;

 ++j;

 }


 do

 {

 cout<<" 1.Display Status \n 2.Book Seat\n 3. Cancel Seat\n";

 cout<<"Select your choice:";

 cin>>choice;

 switch(choice)

 {

 case 1:

 j=1;

 for(int i=1;i<10;i++)

 {

 cout<<j<<"\t";

 c[i].show();

 cout<<endl;

 ++j;

 }


 case 2:

 cout<<"Enter number of row in which you want to book a seat:";

 cin>>row;

 c[row].book_tkt();

 j=1;

 for(int k=0;k<7;k++)

 {

 cout<<"\t"<<j;

 ++j;

 }


 cout<<endl;

 j=1;

 for(int i=1;i<10;i++)

 {

 cout<<j<<"\t";

 c[i].show();

 cout<<endl;

 ++j;

 }

 break;


 case 3:

 cout<<"Enter number of row from which you want to cancel a seat:";

 cin>>row;

 c[row].cancel_tkt();

 j=1;

 for(int k=0;k<7;k++)

 {

 cout<<"\t"<<j;

 j++;

 }


 cout<<endl;

 j=1;

 for(int i=1;i<10;i++)

 {

 cout<<j<<"\t";

 c[i].show();

 cout<<endl;

 ++j;

 }

 break;


 default:

 cout<<"\n Invalid choice:";


 }

 cout<<"\n\n Do you want to continue? (y/n):";

 cin>>ans;

 }while(ans=='y');

 return 0;

 }



Output:

GALLERY

GALLERY
photos

ABOUT

HTML CSS, VB.net Developer and Java, C programming. With Loves Problem Solving and to Unreval the Mysteries behind the Magic of Computer Programming

Followers

MY PROJECTS

Popular posts from this blog

FDS 5

 Practical No: -5 Experiment No. 6: Write a python program to store first year percentage of students in array. Write function for sorting array of floating-point numbers in ascending order using a) Selection Sort b) Bubble sort and display top five score Code: # Function for Selection Sort of elements def Selection_Sort(marks):  for i in range(len(marks)):  # Find the minimum element in remaining unsorted array  min_idx = i  for j in range(i + 1, len(marks)):  if marks[min_idx] > marks[j]:  min_idx = j  # Swap the minimum element with the first element  marks[i], marks[min_idx] = marks[min_idx], marks[i]  print("Marks of students after performing Selection Sort on the list : ")  for i in range(len(marks)):  print(marks[i]) #<---------------------------------------------------------------------------------------> # Function for Bubble Sort of elements def Bubble_Sort(marks):  n = len(marks)  # Traverse throug...

FDS 4

 Practical No: -4 Experiment No. 4: a) Write a python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using linear search and sentinel search. b) Write a Python program to store roll numbers of student array who attended training program in sorted order. Write function for searching whether particular student attended training program or not, using Binary search and Fibonacci search. Code: import array as arr # Accept the Roll Numbers of the students def accept_roll():  a = arr.array('I', [])  no_stud = int(input("Enter the number of Students : "))  for i in range(0, no_stud):  a.append(int(input("Enter the Roll Number : ")))  return a # Print the Roll Numbers of the Students def print_roll(a):  for i in range(0, len(a)):  print("\t", a[i], end=" ")  print() # Linear Search def linear_search(a, x):  f...

Contact us

Name

Email *

Message *