Sie sind auf Seite 1von 22

DSA PROJECT

GROUP-7

TOPIC- Develop a movie ticket


booking system.

Submitted by-
1-Mehul Kumar Jain(1706587)
2-Rajdeep Nagar(1706588)
3-Ankur Tiwari(1706589)
4-Vaibhav Jaipuriya(1706590)
5-Anunay Amrit(1706591)
6-Shivam Sharma(1706592)
7-Amit Kumar(1706593)
8-Avishek Das(1706594)
9-Mohit Kumar(1706595)

Movie ticket Booking System

Movie Ticket Booking System is based on the


concept to generate the Movie records and to add
& update it.Here User can add Movie title with
their ticket price and release date details safely
and it’s not time consuming. This System makes
easy to store records of each and every employees.
The whole project is designed in ‘C’ language and
different variables and strings have been used for
the development of this project. This mini project
is easy to operate and understand by the users.
Program-
This program would ask user to devlop a movie ticket booking
system.
//Creating Functions
//Declaring Variables
//Using loop and switch statements.
//Display Result Statements.

Here is C code for the development of Movie ticket booking


System.

#include<stdio.h>
#include<stdlib.h>

void login()
{
int a=0,i=0;
char uname[10],c=' ';
char pword[10],code[10];
char user[10]="user";
char pass[10]="pass";
do
{printf("\n++++++++++++++++++++++++++++++LOGIN-FIRST+++++
+++++++++++++++++++++++++ ");
printf(" \n\n ENTER USERNAME:-");
scanf("%s", &uname);
printf(" \n\n ENTER PASSWORD:-");
while(i<10)
{
pword[i]=getch();
c=pword[i];
if(c==13) break;
else printf("*");
i++;
}
pword[i]='\0';
//char code=pword;
i=0;
//scanf("%s",&pword);
if(strcmp(uname,"user")==0&&strcmp(pword,"pass")==0)
{
printf("\n\n\n WELCOME TO OUR BOOKING SYSTEM !!!!
LOGIN IS SUCCESSFUL");
printf("\n\n\n\t\t\t\t Press any key to continue...");
getch();//holds the screen
break;
}
else
{
printf("\n SORRY !!!! LOGIN IS UNSUCESSFUL");
a++;

getch();//holds the screen


}
}
while(a<=2);
if (a>2)
{
printf("\nSorry you have entered the wrong username
and password for four times!!!");
getch();
}
system("cls");
}

struct book
{
char code[20];
char name[20];
char date[20];
int cost;}b;
int seat = 60 ;
void insert_details();//for inserting movie details
void viewAll(); // for view all data
void find(); // for finding data
void book_ticket(); //for booking tickets
void old_record(); //for view old recorrds of users,booked
tickets

void main()
{
login();
int ch;
do{
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++");
printf("\n");
printf("\t Moive Ticket booking ");
printf("\n");
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++");
printf("\nEnter >1< To Insert Movie");
printf("\nEnter >2< To View All Movie");
printf("\nEnter >3< To Find Movie ");
printf("\nEnter >4< To Book Tickets");
printf("\nEnter >5< To View All Transactions");
printf("\nEnter >0< To Exit ");
printf("\nEnter your Choice ::");
scanf("%d",&ch); system("cls");
switch (ch)
{
case 1 :
insert_details();
break;
case 2:
viewAll();
break;
case 3:
find();
break;
case 4:
book_ticket();
break;
case 5:
old_record();
break;
case 0:
exit(0);
break;
default:
printf("Wrong choice !");
break;
}
}while(ch!=0);
}

void insert_details()

{
FILE *fp;
struct book b;
printf("Enter movie code :- ");
scanf("%s",b.code);
printf("Enter name :- ");
scanf("%s",b.name);
printf("Enter Release Date:- ");
scanf("%s",b.date);
printf("Enetr Ticket Price:- ");
scanf("%d",&b.cost);
fp=fopen("data.txt","a");
if(fp == NULL)
{
printf("FIle not Found");
}
else
{
fprintf(fp,"%s %s %s %d
\n",b.code,b.name,b.date,b.cost);
printf("Recorded Successfully");
}
printf("\n");
fclose(fp);
system("cls");
}

void find() //find details

{
struct book b;
FILE *fp;
char ch[20];
printf("Enter movie code :");
scanf("%s",ch);
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);}
else
{
while(getc(fp) != EOF)
{

fscanf(fp,"%s %s %s %d",b.code,b.name,b.date,&b.cost);
if(strcmp(b.code,ch) == 0)
{

//printf("%s/%s/%s/%d\n",b.code,b.name,b.date,b.cost);
printf("\n Record Found\n");
printf("\n\t\tCode ::%s",b.code);
printf("\n\t\tmovie name ::%s",b.name);
printf("\n\t\tmovie date ::%s",b.date);
printf("\n\t\tprice of ticket ::%d",b.cost);
}
}
}
fclose(fp);
system("cls");
}

void viewAll()

{
char ch;
FILE *fp;
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);}
else
{
system("cls");
while( ( ch = fgetc(fp) ) != EOF )
printf("%c",ch);}
fclose(fp);

void book_ticket()

{
struct book b;
FILE *fp;
FILE *ufp;
int total_seat,mobile,total_amount;
char name[20];

char ch; //used in display all movies


char movie_code[20]; //for searching
// disply all moives by default for movie code
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);}
else
{
system("cls");
while( ( ch = fgetc(fp) ) != EOF )
printf("%c",ch);}
fclose(fp);

//display ends
printf("\n For Book ticket Choice Movie(Enter Movie Code
First Latter Of Movie)\n");
printf("\n Enter movie code :");
scanf("%s",movie_code);
//system("clear");
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);}
else
{
while(getc(fp) != EOF)
{

fscanf(fp,"%s %s %s %d",b.code,b.name,b.date,&b.cost);
if(strcmp(b.code,movie_code) == 0)
{
//printf("%s / %s / %s
/ %d\n",b.code,b.name,b.date,b.cost);
printf("\n Record Found\n");
printf("\n\t\tCode ::%s",b.code);
printf("\n\t\tMovie name ::%s",b.name);
printf("\n\t\tdate name ::%s",b.date);
printf("\n\t\tPrice of ticket::%d",b.cost);
}
}
}
printf("\n* Fill Deatails *");
printf("\n your name :");
scanf("%s",name);
printf("\n mobile number :");
scanf("%d",&mobile);
printf("\n Total number of tickets :");
scanf("%d",&total_seat);
total_amount = b.cost * total_seat;
printf("\n ENJOY MOVIE \n");
printf("\n\t\tname : %s",name);
printf("\n\t\tmobile Number : %d",mobile);
printf("\n\t\tmovie name : %s",b.name);
printf("\n\t\tTotal seats : %d",total_seat);
printf("\n\t\tcost per ticket : %d",b.cost);
printf("\n\t\tTotal Amount : %d",total_amount);
ufp=fopen("oldTransection.txt","a");
if(ufp == NULL)
{
printf("FIle not Found");
}
else
{
fprintf(ufp,"%s %d %d %d %s %d
\n",name,mobile,total_seat,total_amount,b.name,b.cost);
printf("\n Record insert Sucessfull to the old record
file");
}
printf("\n");
fclose(ufp);
fclose(fp);}
//for view all user transaction
void old_record()
{ char ch;
FILE *fp; //system("clear");
fp = fopen("oldTransaction.txt","r");
if(fp == NULL)
{printf("file does not found !");
exit(1);}
else
{ system("cls");
while( ( ch = fgetc(fp) ) != EOF )
printf("%c",ch);}
fclose(fp);
}

Output:

The outputs for the following code are:


Functions:

This C code contains some of the functions which are


discussed below.
1-void_login();
This function logs in the customer executive to the
book tickets for its customers taking username and password
as inputs.
2-void insert_details();
This function is used to inserting data regarding the movie
and shows the information in the text file as record.
3-void viewAll();
This function is used to display all the details which is
entered by user for each movie’s tickets booked through the
window.
4-void find();
This function takes the “movie_code” as an input and search
for that particular movie and display the details of each
movies,if it is not found it would show you some error.
5-void book_ticket();
It takes all the credentials about the movie as an input and
also take some necessary credentials of the customer who is
booking the tickets.After all the credentials are entered,it
stores the information in its record and display the movie
ticket details back to display.
6-void old_record(); It shows all the older transactions made
for booking the movie tickets through the window.