The document describes a simple movie ticket booking system with the following functionality:
1) Users can book tickets, check showtimes/availability, or exit.
2) When booking, the user selects a movie, showtime, row, and number of seats. The system updates an availability matrix and prints the new status.
3) Multiple matrices track availability for different movies/showtimes. The correct matrix is printed or updated based on the user's selection.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
147 views5 pages
Simple Movie Ticket Booking System Logic
The document describes a simple movie ticket booking system with the following functionality:
1) Users can book tickets, check showtimes/availability, or exit.
2) When booking, the user selects a movie, showtime, row, and number of seats. The system updates an availability matrix and prints the new status.
3) Multiple matrices track availability for different movies/showtimes. The correct matrix is printed or updated based on the user's selection.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5
Simple movie ticket booking system
So firstly we should understand what we actually want in our booking system .
We want that our programe should ask the user about three choices that is booking enquiry and exit . Then in the next part we want that if the user chooses enquiry then all the information about the movies shows timings and tickets must be made available there. But if the user enters for booking the tickets then the system should ask the user about the 1)Movie choices 2)Show timings 3)Then it should display the movie hall and ask for the rows and number of seats he/she wants and accordingly books the tickets in the hall and update the information in the system that this much seats have been booked and will show that seats as filled 4)At last it should display that your tickets are successfully booked Logic for the simple movie ticket booking system • Firstly we have declared the 4 function according to our need for the programme • 1)First function is To print 2D matrix of type char. • 2) 2nd function is To clear the matrix. • 3) 3rd function declaration is the Book function It takes input as a 2D char matrix, movie no. and show time. • 4) 4th function Copies array: [mat2 = mat1] will be result. • Then in the main function ,like for a movie ticket booking system we want to have the choices that weather we want to go for booking ,enquiry or we want to exit from the window so for this we have used a while loop and specified characters (B=booking , E=enquiry , e=exit) and inside the infinite while loop we have used conditional statement if else to ask for the users choice. • Now if the code gets into the body of if statement there are various scanf function to take specify time and movie etc from the user and the calling of book(mt,m,ch2) function which is defined in the later part of the programme for the next execution of the programme . • The second else if is for the enquiry where the user can find the status of movie hall that is how many seats are booked how many seats are empty according to his/her time and can book accordingly . After this there is else statement for exit and the while loop is terminated as we have used break statement . • Now if the user has opted for booking, the programme will go to the while loop and inside it in the body of while loop and will there encounter book function and will go to the book function definition . • So inside the book function definition we want that the programme gives the information about the booked seats and vacant seats and according to the previous choice of the user takes further more input from the user about the row and number of seats as:-- • every character has ASCII value (decimal or hex) • when operated with integer ASCII value of character is used • Also when the user inputs the no. of tickets to be booked is greater than 10 the code returns to main() and runs again. So, at a time not more than 10 tickets can be booked. • Now after entering the seat number and number of seats wanted we want that in the hall that much number of seats must be starred with this (*) and must be shown in the enquiry also if any other person does that after booking is done by some first person. • So to solve the first problem we have stored the value of ‘n’ in temporary variable ‘no’ and applied a condition that if {20-s+1>=n} where ‘s’ is the starting no. of seat to be booked from, then all the tickets can be booked in the same row. Suppose s=18 (starting seat no. to be booked from) and n=2, so {20-18+1(=3)>= 2}. So, it executes the while loop with condition (no>0) and for every iteration no-- is executed. So the no. of booked tickets are shown and stored as (*). • Now if selected starting seat is s=18 and no. of tickets n=5, then condition {20-s+1>=n} becomes false and it moves to else part of the code. Here, according to the starting seat no. (s) the column index (j ranges from 0 to 19) is updated as j = s-1. So, in selected row the remaining seats till 20th seat will be booked. Simultaneously no will be reduced in every iteration. • Further it enters in the while loop with condition (no>0) and it books remaining tickets in next row from seat number 1 (j = 0). In every iteration j is increased by 1 as j++ and no is reduced by 1 as no--. • After this, again using selected movie and show time correct respective matrix is chosen and the temporary matrix (mt on which all the operations are performed) is copied in it. Thus, the status of the booked seats and vacant seats is stored. Also, matrix( mt) is printed using printmat(mt) function. • After this the code returns to the main function and clears the temporary matrix (mt) using clearmat(mt) function. • Then again goes to the starting of main() to further wait for the user input.
Summarising the overall login:
• For each movie and each show time a matrix has been assigned. Suppose movie 1 and afternoon show is selected then corresponding to this matrix m1a is selected to store the values of temporary matrix mt. • Booking of seat is shown by writing * to the selected row and column of the respective matrix. • For enquiry movie no and show time is used to print the current status of selected matrix. For example if movie 2 is selected and enquiry is done for evening show then m2e matrix is printed. • If user wants to exit the code, simply ‘e’ has to be pressed which breaks the infinite while loop and execution gets over.